UNPKG

@dcl/ecs

Version:
157 lines (156 loc) 4.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.defineTweenComponent = void 0; const index_gen_1 = require("../generated/index.gen"); const TweenHelper = { Move(move) { return { $case: 'move', move }; }, MoveContinuous(moveContinuous) { return { $case: 'moveContinuous', moveContinuous }; }, Rotate(rotate) { return { $case: 'rotate', rotate }; }, RotateContinuous(rotateContinuous) { return { $case: 'rotateContinuous', rotateContinuous }; }, Scale(scale) { return { $case: 'scale', scale }; }, TextureMove(textureMove) { return { $case: 'textureMove', textureMove }; }, TextureMoveContinuous(textureMoveContinuous) { return { $case: 'textureMoveContinuous', textureMoveContinuous }; } }; function defineTweenComponent(engine) { const theComponent = (0, index_gen_1.Tween)(engine); return { ...theComponent, Mode: TweenHelper, setMove(entity, start, end, duration, easingFunction = 0 /* EasingFunction.EF_LINEAR */) { theComponent.createOrReplace(entity, { mode: { $case: 'move', move: { start, end } }, duration, easingFunction, playing: true }); }, setScale(entity, start, end, duration, easingFunction = 0 /* EasingFunction.EF_LINEAR */) { theComponent.createOrReplace(entity, { mode: { $case: 'scale', scale: { start, end } }, duration, easingFunction, playing: true }); }, setRotate(entity, start, end, duration, easingFunction = 0 /* EasingFunction.EF_LINEAR */) { theComponent.createOrReplace(entity, { mode: { $case: 'rotate', rotate: { start, end } }, duration, easingFunction, playing: true }); }, setTextureMove(entity, start, end, duration, movementType = 0 /* TextureMovementType.TMT_OFFSET */, easingFunction = 0 /* EasingFunction.EF_LINEAR */) { theComponent.createOrReplace(entity, { mode: { $case: 'textureMove', textureMove: { start, end, movementType } }, duration, easingFunction, playing: true }); }, setMoveContinuous(entity, direction, speed, duration = 0) { theComponent.createOrReplace(entity, { mode: { $case: 'moveContinuous', moveContinuous: { direction, speed } }, duration, easingFunction: 0 /* EasingFunction.EF_LINEAR */, playing: true }); }, setRotateContinuous(entity, direction, speed, duration = 0) { theComponent.createOrReplace(entity, { mode: { $case: 'rotateContinuous', rotateContinuous: { direction, speed } }, duration, easingFunction: 0 /* EasingFunction.EF_LINEAR */, playing: true }); }, setTextureMoveContinuous(entity, direction, speed, movementType = 0 /* TextureMovementType.TMT_OFFSET */, duration = 0) { theComponent.createOrReplace(entity, { mode: { $case: 'textureMoveContinuous', textureMoveContinuous: { direction, speed, movementType } }, duration, easingFunction: 0 /* EasingFunction.EF_LINEAR */, playing: true }); } }; } exports.defineTweenComponent = defineTweenComponent;