babylonjs-editor-tools 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.node.js +1318 -0
- package/build/src/cinematic/events/apply-impulse.js +12 -0
- package/build/src/cinematic/events/set-enabled.js +5 -0
- package/build/src/cinematic/generate.js +134 -0
- package/build/src/cinematic/parse.js +99 -0
- package/build/src/cinematic/tools.js +66 -0
- package/build/src/cinematic/typings.js +2 -0
- package/build/src/decorators/apply.js +71 -0
- package/build/{decorators → src/decorators}/gui.js +1 -5
- package/build/src/decorators/inspector.js +131 -0
- package/build/src/decorators/particle-systems.js +15 -0
- package/build/{decorators → src/decorators}/scene.js +16 -7
- package/build/{decorators → src/decorators}/sound.js +1 -5
- package/build/src/index.js +17 -0
- package/build/src/loading/loader.js +55 -0
- package/build/src/loading/physics.js +28 -0
- package/build/src/loading/rendering.js +30 -0
- package/build/src/loading/script.js +35 -0
- package/build/src/loading/sound.js +14 -0
- package/build/{texture.js → src/loading/texture.js} +9 -11
- package/build/{rendering → src/rendering}/default-pipeline.js +40 -15
- package/build/src/rendering/motion-blur.js +42 -0
- package/build/{rendering → src/rendering}/ssao.js +11 -15
- package/build/{rendering → src/rendering}/ssr.js +11 -15
- package/build/src/rendering/tools.js +51 -0
- package/build/src/rendering/vls.js +57 -0
- package/build/src/script.js +2 -0
- package/build/{guards.js → src/tools/guards.js} +3 -9
- package/build/src/tools/light.js +25 -0
- package/build/src/tools/scalar.js +8 -0
- package/build/src/tools/sound.js +19 -0
- package/build/src/tools/texture.js +16 -0
- package/package.json +24 -6
- package/build/decorators/apply.js +0 -42
- package/build/decorators/apply.js.map +0 -1
- package/build/decorators/gui.js.map +0 -1
- package/build/decorators/scene.js.map +0 -1
- package/build/decorators/sound.js.map +0 -1
- package/build/guards.js.map +0 -1
- package/build/index.js +0 -26
- package/build/index.js.map +0 -1
- package/build/light.js +0 -30
- package/build/light.js.map +0 -1
- package/build/loader.js +0 -87
- package/build/loader.js.map +0 -1
- package/build/physics.js +0 -33
- package/build/physics.js.map +0 -1
- package/build/rendering/default-pipeline.js.map +0 -1
- package/build/rendering/motion-blur.js +0 -46
- package/build/rendering/motion-blur.js.map +0 -1
- package/build/rendering/ssao.js.map +0 -1
- package/build/rendering/ssr.js.map +0 -1
- package/build/script.js +0 -3
- package/build/script.js.map +0 -1
- package/build/texture.js.map +0 -1
- package/build/tools/scalar.js +0 -12
- package/build/tools/scalar.js.map +0 -1
- package/declaration/decorators/apply.d.ts +0 -23
- package/declaration/decorators/gui.d.ts +0 -12
- package/declaration/decorators/scene.d.ts +0 -17
- package/declaration/decorators/sound.d.ts +0 -8
- package/declaration/guards.d.ts +0 -18
- package/declaration/index.d.ts +0 -9
- package/declaration/light.d.ts +0 -3
- package/declaration/loader.d.ts +0 -31
- package/declaration/physics.d.ts +0 -6
- package/declaration/rendering/default-pipeline.d.ts +0 -11
- package/declaration/rendering/motion-blur.d.ts +0 -8
- package/declaration/rendering/ssao.d.ts +0 -8
- package/declaration/rendering/ssr.d.ts +0 -8
- package/declaration/script.d.ts +0 -13
- package/declaration/texture.d.ts +0 -1
- package/declaration/tools/scalar.d.ts +0 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Vector3 } from "@babylonjs/core/Maths/math.vector";
|
|
2
|
+
export function handleApplyImpulseEvent(scene, config) {
|
|
3
|
+
const meshes = config.mesh
|
|
4
|
+
? [scene.getNodeById(config.mesh)]
|
|
5
|
+
: scene.meshes;
|
|
6
|
+
meshes.forEach((mesh) => {
|
|
7
|
+
if (mesh.physicsAggregate?.body) {
|
|
8
|
+
mesh.physicsAggregate.body.applyImpulse(Vector3.FromArray(config.force), Vector3.FromArray(config.contactPoint));
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=apply-impulse.js.map
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { Tools } from "@babylonjs/core/Misc/tools";
|
|
2
|
+
import { Animation } from "@babylonjs/core/Animations/animation";
|
|
3
|
+
import { AnimationEvent } from "@babylonjs/core/Animations/animationEvent";
|
|
4
|
+
import { AnimationGroup } from "@babylonjs/core/Animations/animationGroup";
|
|
5
|
+
import { getDefaultRenderingPipeline } from "../rendering/default-pipeline";
|
|
6
|
+
import { handleSetEnabledEvent } from "./events/set-enabled";
|
|
7
|
+
import { handleApplyImpulseEvent } from "./events/apply-impulse";
|
|
8
|
+
import { cloneKey, getAnimationTypeForObject, getPropertyValue } from "./tools";
|
|
9
|
+
/**
|
|
10
|
+
* Parses the given cinematic object and generates a new playable animation group.
|
|
11
|
+
* @param cinematic defines the cinematic object to parse that was previously loaded.
|
|
12
|
+
* @param scene defines the reference to the scene where to retrieve the animated objects.
|
|
13
|
+
*/
|
|
14
|
+
export function generateCinematicAnimationGroup(cinematic, scene) {
|
|
15
|
+
const result = new AnimationGroup(cinematic.name, scene);
|
|
16
|
+
cinematic.tracks.forEach((track) => {
|
|
17
|
+
// Animation groups
|
|
18
|
+
const animationGroup = track.animationGroup;
|
|
19
|
+
if (animationGroup) {
|
|
20
|
+
track.animationGroups?.forEach((configuration) => {
|
|
21
|
+
animationGroup.targetedAnimations.forEach((targetedAnimation) => {
|
|
22
|
+
let animation = null;
|
|
23
|
+
defer: {
|
|
24
|
+
const existingTargetedAnimations = result.targetedAnimations.filter((ta2) => ta2.target === targetedAnimation.target);
|
|
25
|
+
if (existingTargetedAnimations.length) {
|
|
26
|
+
const existingTargetedAnimationsPair = existingTargetedAnimations.find((et) => et.animation.targetProperty === targetedAnimation.animation.targetProperty);
|
|
27
|
+
if (existingTargetedAnimationsPair) {
|
|
28
|
+
animation = existingTargetedAnimationsPair.animation;
|
|
29
|
+
break defer;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
animation = targetedAnimation.animation.clone();
|
|
33
|
+
animation.setKeys([]);
|
|
34
|
+
animation.name = Tools.RandomId();
|
|
35
|
+
animation.framePerSecond = cinematic.framesPerSecond;
|
|
36
|
+
}
|
|
37
|
+
const keys = animation.getKeys();
|
|
38
|
+
const sourceKeys = targetedAnimation.animation.getKeys();
|
|
39
|
+
const speed = configuration.speed;
|
|
40
|
+
const normalizedFps = (cinematic.framesPerSecond / targetedAnimation.animation.framePerSecond) / speed;
|
|
41
|
+
sourceKeys.forEach((k) => {
|
|
42
|
+
if (k.frame >= configuration.startFrame && k.frame <= configuration.endFrame) {
|
|
43
|
+
keys.push({
|
|
44
|
+
...cloneKey(targetedAnimation.animation.dataType, k),
|
|
45
|
+
frame: configuration.frame + k.frame * normalizedFps,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
animation.setKeys(keys);
|
|
50
|
+
result.addTargetedAnimation(animation, targetedAnimation.target);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
const sound = track.sound;
|
|
55
|
+
const soundBuffer = sound?.getAudioBuffer();
|
|
56
|
+
if (sound && soundBuffer && track.sounds?.length) {
|
|
57
|
+
const dummyObject = {
|
|
58
|
+
dummy: 0,
|
|
59
|
+
};
|
|
60
|
+
const soundAnimation = new Animation(sound.name, "dummy", 60, Animation.ANIMATIONTYPE_FLOAT, Animation.ANIMATIONLOOPMODE_CYCLE, false);
|
|
61
|
+
let maxFrame = 0;
|
|
62
|
+
track.sounds?.forEach((configuration) => {
|
|
63
|
+
const duration = configuration.endFrame - configuration.startFrame;
|
|
64
|
+
maxFrame = Math.max(maxFrame, configuration.frame + duration);
|
|
65
|
+
soundAnimation.addEvent(new AnimationEvent(configuration.frame, (currentFrame) => {
|
|
66
|
+
const frameDiff = currentFrame - configuration.frame;
|
|
67
|
+
const offset = (frameDiff + configuration.startFrame) / cinematic.framesPerSecond;
|
|
68
|
+
// sound.stop();
|
|
69
|
+
sound.play(0, offset);
|
|
70
|
+
}, false));
|
|
71
|
+
soundAnimation.addEvent(new AnimationEvent(configuration.frame + duration, () => {
|
|
72
|
+
sound.stop();
|
|
73
|
+
}));
|
|
74
|
+
});
|
|
75
|
+
soundAnimation.setKeys([
|
|
76
|
+
{ frame: 0, value: 0 },
|
|
77
|
+
{ frame: maxFrame, value: maxFrame },
|
|
78
|
+
]);
|
|
79
|
+
result.addTargetedAnimation(soundAnimation, dummyObject);
|
|
80
|
+
}
|
|
81
|
+
if (track.keyFrameEvents) {
|
|
82
|
+
const dummyObject = {
|
|
83
|
+
dummy: 0,
|
|
84
|
+
};
|
|
85
|
+
const eventsAnimation = new Animation("events", "dummy", 60, Animation.ANIMATIONTYPE_FLOAT, Animation.ANIMATIONLOOPMODE_CYCLE, false);
|
|
86
|
+
let maxFrame = 0;
|
|
87
|
+
track.keyFrameEvents?.forEach((configuration) => {
|
|
88
|
+
maxFrame = Math.max(maxFrame, configuration.frame);
|
|
89
|
+
eventsAnimation.addEvent(new AnimationEvent(configuration.frame, () => {
|
|
90
|
+
switch (configuration.data?.type) {
|
|
91
|
+
case "set-enabled":
|
|
92
|
+
handleSetEnabledEvent(scene, configuration.data);
|
|
93
|
+
break;
|
|
94
|
+
case "apply-impulse":
|
|
95
|
+
handleApplyImpulseEvent(scene, configuration.data);
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
}));
|
|
99
|
+
});
|
|
100
|
+
eventsAnimation.setKeys([
|
|
101
|
+
{ frame: 0, value: 0 },
|
|
102
|
+
{ frame: maxFrame, value: maxFrame },
|
|
103
|
+
]);
|
|
104
|
+
result.addTargetedAnimation(eventsAnimation, dummyObject);
|
|
105
|
+
}
|
|
106
|
+
const node = track.defaultRenderingPipeline ? getDefaultRenderingPipeline() : track.node;
|
|
107
|
+
if (!node || !track.propertyPath || !track.keyFrameAnimations) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const value = getPropertyValue(node, track.propertyPath);
|
|
111
|
+
const animationType = getAnimationTypeForObject(value);
|
|
112
|
+
if (animationType === null) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const animation = new Animation(track.propertyPath, track.propertyPath, 60, animationType, Animation.ANIMATIONLOOPMODE_CYCLE, false);
|
|
116
|
+
const keys = [];
|
|
117
|
+
track.keyFrameAnimations?.forEach((keyFrame) => {
|
|
118
|
+
const animationKey = keyFrame.type === "key" ? keyFrame : null;
|
|
119
|
+
if (animationKey) {
|
|
120
|
+
return keys.push(animationKey);
|
|
121
|
+
}
|
|
122
|
+
const animationKeyCut = keyFrame.type === "cut" ? keyFrame : null;
|
|
123
|
+
if (animationKeyCut) {
|
|
124
|
+
keys.push(animationKeyCut.key1);
|
|
125
|
+
keys.push(animationKeyCut.key2);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
animation.setKeys(keys);
|
|
129
|
+
result.addTargetedAnimation(animation, node);
|
|
130
|
+
});
|
|
131
|
+
result.normalize();
|
|
132
|
+
return result;
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=generate.js.map
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Animation } from "@babylonjs/core/Animations/animation";
|
|
2
|
+
import { Color3, Color4 } from "@babylonjs/core/Maths/math.color";
|
|
3
|
+
import { Quaternion, Vector2, Vector3, Matrix } from "@babylonjs/core/Maths/math.vector";
|
|
4
|
+
import { getDefaultRenderingPipeline } from "../rendering/default-pipeline";
|
|
5
|
+
import { getSoundById } from "../tools/sound";
|
|
6
|
+
import { getAnimationTypeForObject, getPropertyValue } from "./tools";
|
|
7
|
+
/**
|
|
8
|
+
* Parses the given JSON data and returns a new cinematic object.
|
|
9
|
+
* @param data defines the JSON data of the cinematic to parse.
|
|
10
|
+
* @param scene defines the reference to the scene used to retrieve cinematic's data.
|
|
11
|
+
*/
|
|
12
|
+
export function parseCinematic(data, scene) {
|
|
13
|
+
return {
|
|
14
|
+
name: data.name,
|
|
15
|
+
framesPerSecond: data.framesPerSecond,
|
|
16
|
+
outputFramesPerSecond: data.outputFramesPerSecond,
|
|
17
|
+
tracks: data.tracks.map((track) => {
|
|
18
|
+
let node = null;
|
|
19
|
+
let animationType = null;
|
|
20
|
+
if (track.node) {
|
|
21
|
+
node = scene.getNodeById(track.node);
|
|
22
|
+
}
|
|
23
|
+
else if (track.defaultRenderingPipeline) {
|
|
24
|
+
node = getDefaultRenderingPipeline();
|
|
25
|
+
}
|
|
26
|
+
if (track.propertyPath) {
|
|
27
|
+
const value = getPropertyValue(node, track.propertyPath);
|
|
28
|
+
animationType = getAnimationTypeForObject(value);
|
|
29
|
+
}
|
|
30
|
+
let sound = null;
|
|
31
|
+
if (track.sound) {
|
|
32
|
+
sound = getSoundById(track.sound, scene);
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
node,
|
|
36
|
+
sound,
|
|
37
|
+
propertyPath: track.propertyPath,
|
|
38
|
+
defaultRenderingPipeline: track.defaultRenderingPipeline,
|
|
39
|
+
animationGroup: track.animationGroup ? scene.getAnimationGroupByName(track.animationGroup) : null,
|
|
40
|
+
animationGroups: track.animationGroups,
|
|
41
|
+
sounds: track.sounds,
|
|
42
|
+
keyFrameEvents: track.keyFrameEvents,
|
|
43
|
+
keyFrameAnimations: node && animationType !== null && track.keyFrameAnimations?.map((keyFrame) => {
|
|
44
|
+
const animationKey = keyFrame.type === "key" ? keyFrame : null;
|
|
45
|
+
if (animationKey) {
|
|
46
|
+
return {
|
|
47
|
+
...animationKey,
|
|
48
|
+
value: parseCinematicKeyValue(animationKey.value, animationType),
|
|
49
|
+
inTangent: parseCinematicKeyValue(animationKey.inTangent, animationType),
|
|
50
|
+
outTangent: parseCinematicKeyValue(animationKey.outTangent, animationType),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const animationKeyCut = keyFrame.type === "cut" ? keyFrame : null;
|
|
54
|
+
if (animationKeyCut) {
|
|
55
|
+
return {
|
|
56
|
+
...animationKeyCut,
|
|
57
|
+
key1: {
|
|
58
|
+
...animationKeyCut.key1,
|
|
59
|
+
value: parseCinematicKeyValue(animationKeyCut.key1.value, animationType),
|
|
60
|
+
inTangent: parseCinematicKeyValue(animationKeyCut.key1.inTangent, animationType),
|
|
61
|
+
outTangent: parseCinematicKeyValue(animationKeyCut.key1.outTangent, animationType),
|
|
62
|
+
},
|
|
63
|
+
key2: {
|
|
64
|
+
...animationKeyCut.key2,
|
|
65
|
+
value: parseCinematicKeyValue(animationKeyCut.key2.value, animationType),
|
|
66
|
+
inTangent: parseCinematicKeyValue(animationKeyCut.key2.inTangent, animationType),
|
|
67
|
+
outTangent: parseCinematicKeyValue(animationKeyCut.key2.outTangent, animationType),
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}),
|
|
72
|
+
};
|
|
73
|
+
}),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Parses the given value and returns the reference to the right value to be animated.
|
|
78
|
+
* @param value defines the raw value to parse (ie. number or array for vectors).
|
|
79
|
+
* @param type defines the type of the property animated.
|
|
80
|
+
* @example [0, 0, 0] with type Animation.ANIMATIONTYPE_VECTOR3 will return a new Vector3(0, 0, 0) object.
|
|
81
|
+
*/
|
|
82
|
+
export function parseCinematicKeyValue(value, type) {
|
|
83
|
+
if (value === null) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
if (value === undefined) {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
switch (type) {
|
|
90
|
+
case Animation.ANIMATIONTYPE_FLOAT: return value;
|
|
91
|
+
case Animation.ANIMATIONTYPE_VECTOR2: return Vector2.FromArray(value);
|
|
92
|
+
case Animation.ANIMATIONTYPE_VECTOR3: return Vector3.FromArray(value);
|
|
93
|
+
case Animation.ANIMATIONTYPE_QUATERNION: return Quaternion.FromArray(value);
|
|
94
|
+
case Animation.ANIMATIONTYPE_COLOR3: return Color3.FromArray(value);
|
|
95
|
+
case Animation.ANIMATIONTYPE_COLOR4: return Color4.FromArray(value);
|
|
96
|
+
case Animation.ANIMATIONTYPE_MATRIX: return Matrix.FromArray(value);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=parse.js.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Size } from "@babylonjs/core/Maths/math.size";
|
|
2
|
+
import { Animation } from "@babylonjs/core/Animations/animation";
|
|
3
|
+
import { Color3, Color4 } from "@babylonjs/core/Maths/math.color";
|
|
4
|
+
import { Quaternion, Vector2, Vector3 } from "@babylonjs/core/Maths/math.vector";
|
|
5
|
+
export function cloneKey(dataType, key) {
|
|
6
|
+
let value;
|
|
7
|
+
switch (dataType) {
|
|
8
|
+
case Animation.ANIMATIONTYPE_FLOAT:
|
|
9
|
+
value = key.value;
|
|
10
|
+
break;
|
|
11
|
+
default:
|
|
12
|
+
value = key.value.clone();
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
value,
|
|
17
|
+
frame: key.frame,
|
|
18
|
+
interpolation: key.interpolation,
|
|
19
|
+
inTangent: dataType === Animation.ANIMATIONTYPE_FLOAT ? key.inTangent : key.inTangent?.clone(),
|
|
20
|
+
outTangent: dataType === Animation.ANIMATIONTYPE_FLOAT ? key.outTangent : key.outTangent?.clone(),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns the animation type according to the given animated property type.
|
|
25
|
+
* @param effectiveProperty defines the reference to the animated property to get its animation type.
|
|
26
|
+
*/
|
|
27
|
+
export function getAnimationTypeForObject(effectiveProperty) {
|
|
28
|
+
if (!isNaN(parseFloat(effectiveProperty)) && isFinite(effectiveProperty)) {
|
|
29
|
+
return Animation.ANIMATIONTYPE_FLOAT;
|
|
30
|
+
}
|
|
31
|
+
else if (effectiveProperty instanceof Quaternion) {
|
|
32
|
+
return Animation.ANIMATIONTYPE_QUATERNION;
|
|
33
|
+
}
|
|
34
|
+
else if (effectiveProperty instanceof Vector3) {
|
|
35
|
+
return Animation.ANIMATIONTYPE_VECTOR3;
|
|
36
|
+
}
|
|
37
|
+
else if (effectiveProperty instanceof Vector2) {
|
|
38
|
+
return Animation.ANIMATIONTYPE_VECTOR2;
|
|
39
|
+
}
|
|
40
|
+
else if (effectiveProperty instanceof Color3) {
|
|
41
|
+
return Animation.ANIMATIONTYPE_COLOR3;
|
|
42
|
+
}
|
|
43
|
+
else if (effectiveProperty instanceof Color4) {
|
|
44
|
+
return Animation.ANIMATIONTYPE_COLOR4;
|
|
45
|
+
}
|
|
46
|
+
else if (effectiveProperty instanceof Size) {
|
|
47
|
+
return Animation.ANIMATIONTYPE_SIZE;
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Returns the current value of the given property of the given object.
|
|
53
|
+
* @param object defines the root object where to parse the property and return its value.
|
|
54
|
+
* @param property defines the path of the property to get its value.
|
|
55
|
+
* @example getPropertyValue(scene, "ambientColor");
|
|
56
|
+
* @example getPropertyValue(scene, "ambientColor.r");
|
|
57
|
+
*/
|
|
58
|
+
export function getPropertyValue(object, property) {
|
|
59
|
+
const parts = property.split('.');
|
|
60
|
+
let value = object;
|
|
61
|
+
for (let i = 0; i < parts.length; ++i) {
|
|
62
|
+
value = value[parts[i]];
|
|
63
|
+
}
|
|
64
|
+
return value;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Vector2, Vector3 } from "@babylonjs/core/Maths/math.vector";
|
|
2
|
+
import { AdvancedDynamicTexture } from "@babylonjs/gui/2D/advancedDynamicTexture";
|
|
3
|
+
export function applyDecorators(scene, object, script, instance, rootUrl) {
|
|
4
|
+
const ctor = instance.constructor;
|
|
5
|
+
if (!ctor) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
// @nodeFromScene
|
|
9
|
+
ctor._NodesFromScene?.forEach((params) => {
|
|
10
|
+
instance[params.propertyKey.toString()] = scene.getNodeByName(params.nodeName);
|
|
11
|
+
});
|
|
12
|
+
// @nodeFromDescendants
|
|
13
|
+
ctor._NodesFromDescendants?.forEach((params) => {
|
|
14
|
+
const descendant = object.getDescendants?.(params.directDescendantsOnly, (node) => node.name === params.nodeName)[0];
|
|
15
|
+
instance[params.propertyKey.toString()] = descendant ?? null;
|
|
16
|
+
});
|
|
17
|
+
// @fromAnimationGroups
|
|
18
|
+
ctor._AnimationGroups?.forEach((params) => {
|
|
19
|
+
instance[params.propertyKey.toString()] = scene.getAnimationGroupByName(params.animationGroupName);
|
|
20
|
+
});
|
|
21
|
+
// @soundFromScene
|
|
22
|
+
ctor._SoundsFromScene?.forEach((params) => {
|
|
23
|
+
const sound = scene.getSoundByName?.(params.soundName);
|
|
24
|
+
instance[params.propertyKey.toString()] = sound ?? null;
|
|
25
|
+
});
|
|
26
|
+
// @guiFromAsset
|
|
27
|
+
ctor._GuiFromAsset?.forEach(async (params) => {
|
|
28
|
+
const guiUrl = `${rootUrl}assets/${params.pathInAssets}`;
|
|
29
|
+
try {
|
|
30
|
+
const response = await fetch(guiUrl);
|
|
31
|
+
const data = await response.json();
|
|
32
|
+
const gui = AdvancedDynamicTexture.CreateFullscreenUI(data.name, true, scene);
|
|
33
|
+
gui.parseSerializedObject(data.content, false);
|
|
34
|
+
instance[params.propertyKey.toString()] = gui;
|
|
35
|
+
params.onGuiCreated?.(instance, gui);
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
console.error(`Failed to load GUI from asset: ${guiUrl}`);
|
|
39
|
+
throw e;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
// @fromParticleSystems
|
|
43
|
+
ctor._ParticleSystemsFromScene?.forEach((params) => {
|
|
44
|
+
const particleSystem = scene.particleSystems?.find((particleSystem) => {
|
|
45
|
+
return particleSystem.name === params.particleSystemName;
|
|
46
|
+
});
|
|
47
|
+
instance[params.propertyKey.toString()] = particleSystem;
|
|
48
|
+
});
|
|
49
|
+
// @visibleAsNumber, @visibleAsBoolean etc.
|
|
50
|
+
ctor._VisibleInInspector?.forEach((params) => {
|
|
51
|
+
const propertyKey = params.propertyKey.toString();
|
|
52
|
+
const attachedScripts = script.values;
|
|
53
|
+
if (attachedScripts.hasOwnProperty(propertyKey) &&
|
|
54
|
+
attachedScripts[propertyKey].hasOwnProperty("value")) {
|
|
55
|
+
const value = attachedScripts[propertyKey].value;
|
|
56
|
+
switch (params.configuration.type) {
|
|
57
|
+
case "number":
|
|
58
|
+
case "boolean":
|
|
59
|
+
instance[propertyKey] = value;
|
|
60
|
+
break;
|
|
61
|
+
case "vector2":
|
|
62
|
+
instance[propertyKey] = Vector2.FromArray(value);
|
|
63
|
+
break;
|
|
64
|
+
case "vector3":
|
|
65
|
+
instance[propertyKey] = Vector3.FromArray(value);
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=apply.js.map
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.guiFromAsset = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Makes the decorated property linked to the GUI created from the given asset file.
|
|
6
3
|
* Once the script is instantiated, the reference to the gui texture is created from the asset file
|
|
@@ -11,12 +8,11 @@ exports.guiFromAsset = void 0;
|
|
|
11
8
|
* @guiFromAsset<MyScriptClass>("ui.gui", (instance, gui) => instance._onGuiLoaded(gui))
|
|
12
9
|
* private _ui!: AdvancedDynamicTexture;
|
|
13
10
|
*/
|
|
14
|
-
function guiFromAsset(pathInAssets, onGuiCreated) {
|
|
11
|
+
export function guiFromAsset(pathInAssets, onGuiCreated) {
|
|
15
12
|
return function (target, propertyKey) {
|
|
16
13
|
const ctor = target.constructor;
|
|
17
14
|
ctor._GuiFromAsset ??= [];
|
|
18
15
|
ctor._GuiFromAsset.push({ propertyKey, pathInAssets, onGuiCreated });
|
|
19
16
|
};
|
|
20
17
|
}
|
|
21
|
-
exports.guiFromAsset = guiFromAsset;
|
|
22
18
|
//# sourceMappingURL=gui.js.map
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Makes the decorated property visible in the editor inspector as a boolean.
|
|
3
|
+
* The property can be customized per object in the editor and the custom value is applied
|
|
4
|
+
* once the script is invoked at runtime in the game/application.
|
|
5
|
+
* This can be used only by scripts using Classes.
|
|
6
|
+
* @param label defines the optional label displayed in the inspector in the editor.
|
|
7
|
+
*/
|
|
8
|
+
export function visibleAsBoolean(label) {
|
|
9
|
+
return function (target, propertyKey) {
|
|
10
|
+
const ctor = target.constructor;
|
|
11
|
+
ctor._VisibleInInspector ??= [];
|
|
12
|
+
ctor._VisibleInInspector.push({
|
|
13
|
+
label,
|
|
14
|
+
propertyKey,
|
|
15
|
+
configuration: {
|
|
16
|
+
type: "boolean",
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Makes the decorated property visible in the editor inspector as a number.
|
|
23
|
+
* The property can be customized per object in the editor and the custom value is applied
|
|
24
|
+
* once the script is invoked at runtime in the game/application.
|
|
25
|
+
* This can be used only by scripts using Classes.
|
|
26
|
+
* @param label defines the optional label displayed in the inspector in the editor.
|
|
27
|
+
* @param configuration defines the optional configuration for the field in the inspector (min, max, etc.).
|
|
28
|
+
*/
|
|
29
|
+
export function visibleAsNumber(label, configuration) {
|
|
30
|
+
return function (target, propertyKey) {
|
|
31
|
+
const ctor = target.constructor;
|
|
32
|
+
ctor._VisibleInInspector ??= [];
|
|
33
|
+
ctor._VisibleInInspector.push({
|
|
34
|
+
label,
|
|
35
|
+
propertyKey,
|
|
36
|
+
configuration: {
|
|
37
|
+
...configuration,
|
|
38
|
+
type: "number",
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Makes the decorated property visible in the editor inspector as a vector2.
|
|
45
|
+
* The property can be customized per object in the editor and the custom value is applied
|
|
46
|
+
* once the script is invoked at runtime in the game/application.
|
|
47
|
+
* This can be used only by scripts using Classes.
|
|
48
|
+
* @param label defines the optional label displayed in the inspector in the editor.
|
|
49
|
+
* @param configuration defines the optional configuration for the field in the inspector (min, max, etc.).
|
|
50
|
+
*/
|
|
51
|
+
export function visibleAsVector2(label, configuration) {
|
|
52
|
+
return function (target, propertyKey) {
|
|
53
|
+
const ctor = target.constructor;
|
|
54
|
+
ctor._VisibleInInspector ??= [];
|
|
55
|
+
ctor._VisibleInInspector.push({
|
|
56
|
+
label,
|
|
57
|
+
propertyKey,
|
|
58
|
+
configuration: {
|
|
59
|
+
...configuration,
|
|
60
|
+
type: "vector2",
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Makes the decorated property visible in the editor inspector as a vector3.
|
|
67
|
+
* The property can be customized per object in the editor and the custom value is applied
|
|
68
|
+
* once the script is invoked at runtime in the game/application.
|
|
69
|
+
* This can be used only by scripts using Classes.
|
|
70
|
+
* @param label defines the optional label displayed in the inspector in the editor.
|
|
71
|
+
* @param configuration defines the optional configuration for the field in the inspector (min, max, etc.).
|
|
72
|
+
*/
|
|
73
|
+
export function visibleAsVector3(label, configuration) {
|
|
74
|
+
return function (target, propertyKey) {
|
|
75
|
+
const ctor = target.constructor;
|
|
76
|
+
ctor._VisibleInInspector ??= [];
|
|
77
|
+
ctor._VisibleInInspector.push({
|
|
78
|
+
label,
|
|
79
|
+
propertyKey,
|
|
80
|
+
configuration: {
|
|
81
|
+
...configuration,
|
|
82
|
+
type: "vector3",
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Makes the decorated property visible in the editor inspector as a color3.
|
|
89
|
+
* The property can be customized per object in the editor and the custom value is applied
|
|
90
|
+
* once the script is invoked at runtime in the game/application.
|
|
91
|
+
* This can be used only by scripts using Classes.
|
|
92
|
+
* @param label defines the optional label displayed in the inspector in the editor.
|
|
93
|
+
* @param configuration defines the optional configuration for the field in the inspector (min, max, etc.).
|
|
94
|
+
*/
|
|
95
|
+
export function visibleAsColor3(label, configuration) {
|
|
96
|
+
return function (target, propertyKey) {
|
|
97
|
+
const ctor = target.constructor;
|
|
98
|
+
ctor._VisibleInInspector ??= [];
|
|
99
|
+
ctor._VisibleInInspector.push({
|
|
100
|
+
label,
|
|
101
|
+
propertyKey,
|
|
102
|
+
configuration: {
|
|
103
|
+
...configuration,
|
|
104
|
+
type: "color3",
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Makes the decorated property visible in the editor inspector as a color4.
|
|
111
|
+
* The property can be customized per object in the editor and the custom value is applied
|
|
112
|
+
* once the script is invoked at runtime in the game/application.
|
|
113
|
+
* This can be used only by scripts using Classes.
|
|
114
|
+
* @param label defines the optional label displayed in the inspector in the editor.
|
|
115
|
+
* @param configuration defines the optional configuration for the field in the inspector (min, max, etc.).
|
|
116
|
+
*/
|
|
117
|
+
export function visibleAsColor4(label, configuration) {
|
|
118
|
+
return function (target, propertyKey) {
|
|
119
|
+
const ctor = target.constructor;
|
|
120
|
+
ctor._VisibleInInspector ??= [];
|
|
121
|
+
ctor._VisibleInInspector.push({
|
|
122
|
+
label,
|
|
123
|
+
propertyKey,
|
|
124
|
+
configuration: {
|
|
125
|
+
...configuration,
|
|
126
|
+
type: "color4",
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=inspector.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Makes the decorated property linked to the particle system that has the given name.
|
|
3
|
+
* Once the script is instantiated, the reference to the particle system is retrieved
|
|
4
|
+
* from the scene and assigned to the property. Node link cant' be used in constructor.
|
|
5
|
+
* This can be used only by scripts using Classes.
|
|
6
|
+
* @param particleSystemName defines the name of the sound to retrieve in scene.
|
|
7
|
+
*/
|
|
8
|
+
export function particleSystemFromScene(particleSystemName) {
|
|
9
|
+
return function (target, propertyKey) {
|
|
10
|
+
const ctor = target.constructor;
|
|
11
|
+
ctor._ParticleSystemsFromScene ??= [];
|
|
12
|
+
ctor._ParticleSystemsFromScene.push({ propertyKey, particleSystemName });
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=particle-systems.js.map
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.nodeFromDescendants = exports.nodeFromScene = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Makes the decorated property linked to the node that has the given name.
|
|
6
3
|
* Once the script is instantiated, the reference to the node is retrieved from the scene
|
|
@@ -8,14 +5,13 @@ exports.nodeFromDescendants = exports.nodeFromScene = void 0;
|
|
|
8
5
|
* This can be used only by scripts using Classes.
|
|
9
6
|
* @param nodeName defines the name of the node to retrieve in scene.
|
|
10
7
|
*/
|
|
11
|
-
function nodeFromScene(nodeName) {
|
|
8
|
+
export function nodeFromScene(nodeName) {
|
|
12
9
|
return function (target, propertyKey) {
|
|
13
10
|
const ctor = target.constructor;
|
|
14
11
|
ctor._NodesFromScene ??= [];
|
|
15
12
|
ctor._NodesFromScene.push({ propertyKey, nodeName });
|
|
16
13
|
};
|
|
17
14
|
}
|
|
18
|
-
exports.nodeFromScene = nodeFromScene;
|
|
19
15
|
/**
|
|
20
16
|
* Makes the decorated property linked to the node that has the given name.
|
|
21
17
|
* Once the script is instantiated, the reference to the node is retrieved from the descendants
|
|
@@ -24,12 +20,25 @@ exports.nodeFromScene = nodeFromScene;
|
|
|
24
20
|
* @param nodeName defines the name of the node to retrieve in scene.
|
|
25
21
|
* @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered.
|
|
26
22
|
*/
|
|
27
|
-
function nodeFromDescendants(nodeName, directDescendantsOnly = false) {
|
|
23
|
+
export function nodeFromDescendants(nodeName, directDescendantsOnly = false) {
|
|
28
24
|
return function (target, propertyKey) {
|
|
29
25
|
const ctor = target.constructor;
|
|
30
26
|
ctor._NodesFromDescendants ??= [];
|
|
31
27
|
ctor._NodesFromDescendants.push({ propertyKey, nodeName, directDescendantsOnly });
|
|
32
28
|
};
|
|
33
29
|
}
|
|
34
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Makes the decorated property linked to an animation group that has the given name.
|
|
32
|
+
* Once the script is instantiated, the reference to the animation group is retrieved from the scene
|
|
33
|
+
* and assigned to the property. Animation group link cant' be used in constructor.
|
|
34
|
+
* This can be used only by scripts using Classes.
|
|
35
|
+
* @param animationGroupName defines the name of the animation group to retrieve in scene.
|
|
36
|
+
*/
|
|
37
|
+
export function animationGroupFromScene(animationGroupName) {
|
|
38
|
+
return function (target, propertyKey) {
|
|
39
|
+
const ctor = target.constructor;
|
|
40
|
+
ctor._AnimationGroups ??= [];
|
|
41
|
+
ctor._AnimationGroups.push({ animationGroupName, propertyKey });
|
|
42
|
+
};
|
|
43
|
+
}
|
|
35
44
|
//# sourceMappingURL=scene.js.map
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.soundFromScene = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Makes the decorated property linked to the sound that has the given name.
|
|
6
3
|
* Once the script is instantiated, the reference to the sound is retrieved from the scene
|
|
@@ -8,12 +5,11 @@ exports.soundFromScene = void 0;
|
|
|
8
5
|
* This can be used only by scripts using Classes.
|
|
9
6
|
* @param soundName defines the name of the sound to retrieve in scene.
|
|
10
7
|
*/
|
|
11
|
-
function soundFromScene(soundName) {
|
|
8
|
+
export function soundFromScene(soundName) {
|
|
12
9
|
return function (target, propertyKey) {
|
|
13
10
|
const ctor = target.constructor;
|
|
14
11
|
ctor._SoundsFromScene ??= [];
|
|
15
12
|
ctor._SoundsFromScene.push({ propertyKey, soundName });
|
|
16
13
|
};
|
|
17
14
|
}
|
|
18
|
-
exports.soundFromScene = soundFromScene;
|
|
19
15
|
//# sourceMappingURL=sound.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from "./loading/loader";
|
|
2
|
+
export * from "./tools/texture";
|
|
3
|
+
export * from "./rendering/ssao";
|
|
4
|
+
export * from "./rendering/ssr";
|
|
5
|
+
export * from "./rendering/motion-blur";
|
|
6
|
+
export * from "./rendering/default-pipeline";
|
|
7
|
+
export * from "./rendering/vls";
|
|
8
|
+
export * from "./decorators/scene";
|
|
9
|
+
export * from "./decorators/gui";
|
|
10
|
+
export * from "./decorators/sound";
|
|
11
|
+
export * from "./decorators/particle-systems";
|
|
12
|
+
export * from "./decorators/inspector";
|
|
13
|
+
export * from "./script";
|
|
14
|
+
export * from "./cinematic/parse";
|
|
15
|
+
export * from "./cinematic/typings";
|
|
16
|
+
export * from "./cinematic/generate";
|
|
17
|
+
//# sourceMappingURL=index.js.map
|