spine连接器和导出修改
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import { build } from 'esbuild'
|
||||
|
||||
const source = `
|
||||
import { buildSpineJson } from './src/export/spineJsonExporter.ts'
|
||||
import { validateSpineJson } from './src/export/spineJsonValidator.ts'
|
||||
|
||||
const resource = {
|
||||
id: 1, imageMode: 'single', sequenceFrames: [], textureName: 'star.png', textureFolder: '',
|
||||
anchorX: 0.5, anchorY: 0.5, blend: 'normal', independentAlpha: 'off',
|
||||
}
|
||||
const frames = Array.from({ length: 31 }, (_, frame) => [{
|
||||
active: true, boneName: 'particle', spawnId: 1, resourceId: 1, imageFrameIndex: 0,
|
||||
imageVisible: true, colorHex: 0xffffff, alpha: 1,
|
||||
x: frame, y: frame / 2, rotation: frame, scaleX: 1, scaleY: 1,
|
||||
worldX: frame, worldY: frame / 2, worldRotation: frame, worldScaleX: 1, worldScaleY: 1,
|
||||
}])
|
||||
const system = {
|
||||
id: 1, animation: 'animation', visible: true, frames,
|
||||
config: {
|
||||
name: 'verify', mode: 'burst', lifeMode: 'fixed', lifeMin: 1, lifeMax: 1, delay: 0,
|
||||
imageResources: [resource], trail: false, trailResources: [],
|
||||
},
|
||||
}
|
||||
const timeline = { fps: 30, animations: ['animation'] }
|
||||
|
||||
let failures = 0
|
||||
for (const version of ['3.8', '4.0', '4.1', '4.2', '4.3']) {
|
||||
const settings = {
|
||||
imagesPath: './images/', spineVersion: version, keyframeCurve: 'linear', fps: 30,
|
||||
omitFps: false, integerFrameAlignment: true, bonePool: true,
|
||||
excludeEmptyAnimations: false, fileName: 'verify.json',
|
||||
}
|
||||
const result = buildSpineJson({ systems: [system], timeline, settings })
|
||||
try {
|
||||
const validation = validateSpineJson(result.text, version)
|
||||
console.log('Spine ' + version + ':', validation.bones + ' bones,', validation.slots + ' slots,', validation.animations + ' animations')
|
||||
} catch (error) {
|
||||
failures++
|
||||
console.error('Spine ' + version + ': ' + (error instanceof Error ? error.message : String(error)))
|
||||
}
|
||||
}
|
||||
if (failures) process.exitCode = 1
|
||||
`
|
||||
|
||||
const result = await build({
|
||||
stdin: { contents: source, resolveDir: process.cwd(), sourcefile: 'verify-spine-json.ts', loader: 'ts' },
|
||||
bundle: true,
|
||||
platform: 'node',
|
||||
format: 'esm',
|
||||
write: false,
|
||||
logLevel: 'silent',
|
||||
})
|
||||
|
||||
const code = Buffer.from(result.outputFiles[0].contents).toString('base64')
|
||||
await import(`data:text/javascript;base64,${code}`)
|
||||
Reference in New Issue
Block a user