@zephyr3d/scene 0.9.24 → 0.9.26
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/dist/animation/hair/gpu_hair_simulation.js +1090 -0
- package/dist/animation/hair/gpu_hair_simulation.js.map +1 -0
- package/dist/animation/joint_dynamics/controller.js +7 -5
- package/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/animation/joint_dynamics/joint_dynamics_system.js +81 -5
- package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
- package/dist/animation/morphtrack.js +3 -4
- package/dist/animation/morphtrack.js.map +1 -1
- package/dist/animation/skeleton.js +58 -24
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/spring/multi_chain_spring_system.js +577 -179
- package/dist/animation/spring/multi_chain_spring_system.js.map +1 -1
- package/dist/animation/spring/spring_collider.js +4 -3
- package/dist/animation/spring/spring_collider.js.map +1 -1
- package/dist/animation/spring/spring_node_pose_tracker.js +40 -0
- package/dist/animation/spring/spring_node_pose_tracker.js.map +1 -0
- package/dist/animation/spring/spring_particle.js +2 -0
- package/dist/animation/spring/spring_particle.js.map +1 -1
- package/dist/animation/spring/spring_system.js +11 -3
- package/dist/animation/spring/spring_system.js.map +1 -1
- package/dist/animation/spring_modifier.js +10 -0
- package/dist/animation/spring_modifier.js.map +1 -1
- package/dist/app/engine.js +53 -43
- package/dist/app/engine.js.map +1 -1
- package/dist/app/scriptingsystem.js +119 -6
- package/dist/app/scriptingsystem.js.map +1 -1
- package/dist/app/scriptregistry.js +3 -2
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/assetmanager.js +284 -67
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/loaders/zhair/zhair_format.js +288 -0
- package/dist/asset/loaders/zhair/zhair_format.js.map +1 -0
- package/dist/asset/loaders/zhair/zhair_loader.js +221 -0
- package/dist/asset/loaders/zhair/zhair_loader.js.map +1 -0
- package/dist/asset/model.js +178 -67
- package/dist/asset/model.js.map +1 -1
- package/dist/camera/camera.js +193 -21
- package/dist/camera/camera.js.map +1 -1
- package/dist/camera/perspectivecamera.js +3 -1
- package/dist/camera/perspectivecamera.js.map +1 -1
- package/dist/index.d.ts +4040 -1290
- package/dist/index.js +16 -6
- package/dist/index.js.map +1 -1
- package/dist/material/eye.js +932 -0
- package/dist/material/eye.js.map +1 -0
- package/dist/material/hair.js +917 -0
- package/dist/material/hair.js.map +1 -0
- package/dist/material/hairstrand.js +842 -0
- package/dist/material/hairstrand.js.map +1 -0
- package/dist/material/hairstrand_data.js +162 -0
- package/dist/material/hairstrand_data.js.map +1 -0
- package/dist/material/lambert.js +5 -2
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +338 -300
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +120 -19
- package/dist/material/meshmaterial.js.map +1 -1
- package/dist/material/mixins/albedocolor.js +1 -1
- package/dist/material/mixins/albedocolor.js.map +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js +5 -3
- package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
- package/dist/material/mixins/lightmodel/lambert.js +5 -4
- package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +3 -3
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +5 -5
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +3 -3
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
- package/dist/material/mixins/lit.js +73 -18
- package/dist/material/mixins/lit.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +4 -4
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/mixins/texture.js +48 -11
- package/dist/material/mixins/texture.js.map +1 -1
- package/dist/material/mtoon.js +6 -5
- package/dist/material/mtoon.js.map +1 -1
- package/dist/material/pbrblueprint.js +146 -28
- package/dist/material/pbrblueprint.js.map +1 -1
- package/dist/material/pbrblueprint_instance.js +501 -0
- package/dist/material/pbrblueprint_instance.js.map +1 -0
- package/dist/material/pbrmr.js +15 -16
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/shader/helper.js +766 -456
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/shader/terrain_blend.js +55 -0
- package/dist/material/shader/terrain_blend.js.map +1 -0
- package/dist/material/skin.js +192 -32
- package/dist/material/skin.js.map +1 -1
- package/dist/material/spriteblueprint.js +16 -1
- package/dist/material/spriteblueprint.js.map +1 -1
- package/dist/material/subsurfaceprofile.js +86 -23
- package/dist/material/subsurfaceprofile.js.map +1 -1
- package/dist/material/water.js +3 -1
- package/dist/material/water.js.map +1 -1
- package/dist/posteffect/bloom.js +167 -7
- package/dist/posteffect/bloom.js.map +1 -1
- package/dist/posteffect/coloradjust.js +2 -1
- package/dist/posteffect/coloradjust.js.map +1 -1
- package/dist/posteffect/compositor.js.map +1 -1
- package/dist/posteffect/fxaa.js +2 -1
- package/dist/posteffect/fxaa.js.map +1 -1
- package/dist/posteffect/grayscale.js +3 -1
- package/dist/posteffect/grayscale.js.map +1 -1
- package/dist/posteffect/motionblur.js +4 -1
- package/dist/posteffect/motionblur.js.map +1 -1
- package/dist/posteffect/posteffect.js.map +1 -1
- package/dist/posteffect/skinsss.js +368 -69
- package/dist/posteffect/skinsss.js.map +1 -1
- package/dist/posteffect/ssgi.js +16 -9
- package/dist/posteffect/ssgi.js.map +1 -1
- package/dist/posteffect/ssr.js +3 -0
- package/dist/posteffect/ssr.js.map +1 -1
- package/dist/posteffect/sss.js +91 -34
- package/dist/posteffect/sss.js.map +1 -1
- package/dist/posteffect/taa.js.map +1 -1
- package/dist/posteffect/tonemap.js +44 -1
- package/dist/posteffect/tonemap.js.map +1 -1
- package/dist/render/abuffer_oit.js +45 -39
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/cluster_light.js +4 -4
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/cull_visitor.js +19 -0
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/depthpass.js +36 -2
- package/dist/render/depthpass.js.map +1 -1
- package/dist/render/drawable_mixin.js +26 -1
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/dualdepthpeeling_oit.js +52 -51
- package/dist/render/dualdepthpeeling_oit.js.map +1 -1
- package/dist/render/envlight.js +1 -1
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/fbm_wavegenerator.js +3 -0
- package/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +3 -0
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/globalbindgroup_allocator.js +3 -0
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/oit.js +29 -0
- package/dist/render/oit.js.map +1 -0
- package/dist/render/render_queue.js +3 -0
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/rendergraph/device_pool_allocator.js.map +1 -1
- package/dist/render/rendergraph/executor.js +2 -0
- package/dist/render/rendergraph/executor.js.map +1 -1
- package/dist/render/rendergraph/forward_plus_builder.js +61 -1
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/render/rendergraph/rendergraph.js.map +1 -1
- package/dist/render/rendergraph/texture_affinity_cache.js +1 -1
- package/dist/render/rendergraph/texture_affinity_cache.js.map +1 -1
- package/dist/render/rendergraph/types.js.map +1 -1
- package/dist/render/shadow_mask_pass.js +73 -8
- package/dist/render/shadow_mask_pass.js.map +1 -1
- package/dist/render/sky.js +166 -126
- package/dist/render/sky.js.map +1 -1
- package/dist/render/weightedblended_oit.js +36 -35
- package/dist/render/weightedblended_oit.js.map +1 -1
- package/dist/scene/basesprite.js +8 -0
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/batchgroup.js +3 -0
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +4 -1
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/hair.js +963 -0
- package/dist/scene/hair.js.map +1 -0
- package/dist/scene/light.js +5 -1
- package/dist/scene/light.js.map +1 -1
- package/dist/scene/mesh.js +481 -47
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/meshdrawable.js +6 -0
- package/dist/scene/meshdrawable.js.map +1 -1
- package/dist/scene/msdftext.js +3 -0
- package/dist/scene/msdftext.js.map +1 -1
- package/dist/scene/msdftextsprite.js +3 -0
- package/dist/scene/msdftextsprite.js.map +1 -1
- package/dist/scene/particlesys.js +6 -0
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/scene.js +3 -0
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +6 -1
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/terrain-cm/grass.js +273 -249
- package/dist/scene/terrain-cm/grass.js.map +1 -1
- package/dist/scene/terrain-cm/grassmaterial.js +3 -0
- package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +6 -0
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/scene/terrain-cm/texture_cache.js +309 -0
- package/dist/scene/terrain-cm/texture_cache.js.map +1 -0
- package/dist/scene/water.js +6 -0
- package/dist/scene/water.js.map +1 -1
- package/dist/shaders/atmosphere.js.map +1 -1
- package/dist/shaders/diffusion.js +54 -0
- package/dist/shaders/diffusion.js.map +1 -0
- package/dist/shaders/shadow.js +33 -21
- package/dist/shaders/shadow.js.map +1 -1
- package/dist/shaders/temporal.js +71 -33
- package/dist/shaders/temporal.js.map +1 -1
- package/dist/shadow/dom.js +546 -0
- package/dist/shadow/dom.js.map +1 -0
- package/dist/shadow/pcf_opt.js +3 -5
- package/dist/shadow/pcf_opt.js.map +1 -1
- package/dist/shadow/pcf_pd.js +1 -1
- package/dist/shadow/pcf_pd.js.map +1 -1
- package/dist/shadow/receiver_bias.js +41 -0
- package/dist/shadow/receiver_bias.js.map +1 -0
- package/dist/shadow/shader.js +20 -60
- package/dist/shadow/shader.js.map +1 -1
- package/dist/shadow/shadow_impl.js +89 -0
- package/dist/shadow/shadow_impl.js.map +1 -1
- package/dist/shadow/shadow_region.js +50 -50
- package/dist/shadow/shadow_region.js.map +1 -1
- package/dist/shadow/shadowmapper.js +150 -37
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shapes/shape.js +11 -2
- package/dist/shapes/shape.js.map +1 -1
- package/dist/shapes/sphere.js +50 -9
- package/dist/shapes/sphere.js.map +1 -1
- package/dist/utility/blueprint/common/constants.js +112 -2
- package/dist/utility/blueprint/common/constants.js.map +1 -1
- package/dist/utility/blueprint/material/func.js +142 -49
- package/dist/utility/blueprint/material/func.js.map +1 -1
- package/dist/utility/blueprint/material/ir.js +490 -25
- package/dist/utility/blueprint/material/ir.js.map +1 -1
- package/dist/utility/blueprint/material/texture.js +898 -4
- package/dist/utility/blueprint/material/texture.js.map +1 -1
- package/dist/utility/serialization/manager.js +431 -100
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +370 -3
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/batch.js +4 -0
- package/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +133 -1
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/common.js +26 -5
- package/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/utility/serialization/scene/hair.js +1141 -0
- package/dist/utility/serialization/scene/hair.js.map +1 -0
- package/dist/utility/serialization/scene/light.js +84 -4
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +1867 -166
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +231 -14
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +141 -7
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/particle.js +4 -0
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/primitive.js +18 -0
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/sprite.js +4 -0
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +92 -69
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/text.js +4 -0
- package/dist/utility/serialization/scene/text.js.map +1 -1
- package/dist/utility/serialization/scene/water.js +4 -0
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/serialization/types.js.map +1 -1
- package/dist/utility/shprojector.js +96 -95
- package/dist/utility/shprojector.js.map +1 -1
- package/dist/values.js +105 -58
- package/dist/values.js.map +1 -1
- package/package.json +3 -3
|
@@ -13,6 +13,13 @@ import { FixedGeometryCacheTrack } from '../../../animation/fixed_geometry_cache
|
|
|
13
13
|
import { BoundingBox } from '../../bounding_volume.js';
|
|
14
14
|
import { PCAGeometryCacheTrack } from '../../../animation/pca_geometry_cache_track.js';
|
|
15
15
|
import { Skeleton, SkeletonRig, SkinBinding } from '../../../animation/skeleton.js';
|
|
16
|
+
import { SpringModifier } from '../../../animation/spring_modifier.js';
|
|
17
|
+
import { createSpringParticle } from '../../../animation/spring/spring_particle.js';
|
|
18
|
+
import { createSpringConstraint } from '../../../animation/spring/spring_constraint.js';
|
|
19
|
+
import { SpringChain } from '../../../animation/spring/spring_chain.js';
|
|
20
|
+
import { SpringSystem } from '../../../animation/spring/spring_system.js';
|
|
21
|
+
import { MultiChainSpringSystem } from '../../../animation/spring/multi_chain_spring_system.js';
|
|
22
|
+
import { createPlaneCollider, createCapsuleCollider, createSphereCollider } from '../../../animation/spring/spring_collider.js';
|
|
16
23
|
import '@zephyr3d/device';
|
|
17
24
|
import '../../../animation/joint_dynamics/collision.js';
|
|
18
25
|
import '../../../animation/joint_dynamics/solver.js';
|
|
@@ -30,7 +37,10 @@ import '../../../material/unlit.js';
|
|
|
30
37
|
import '../../../material/particle.js';
|
|
31
38
|
import '../../../material/subsurfaceprofile.js';
|
|
32
39
|
import '../../../material/skin.js';
|
|
40
|
+
import '../../../material/eye.js';
|
|
33
41
|
import '../../../material/meshmaterial.js';
|
|
42
|
+
import '../../../material/hair.js';
|
|
43
|
+
import '../../../material/hairstrand.js';
|
|
34
44
|
import '../../../material/grassmaterial.js';
|
|
35
45
|
import '../../../material/terrain-cm.js';
|
|
36
46
|
import '../../../material/pbrmr.js';
|
|
@@ -55,6 +65,7 @@ import '../../../scene/meshdrawable.js';
|
|
|
55
65
|
import '../../../scene/basesprite.js';
|
|
56
66
|
import '../../../material/msdf_text.js';
|
|
57
67
|
import '../../../scene/water.js';
|
|
68
|
+
import '../../../scene/hair.js';
|
|
58
69
|
import '../../../scene/particlesys.js';
|
|
59
70
|
import '../../../scene/batchgroup.js';
|
|
60
71
|
import '../../../scene/terrain-cm/terrain-cm.js';
|
|
@@ -62,6 +73,7 @@ import '../../../scene/terrain-cm/grass.js';
|
|
|
62
73
|
import '../../../scene/raycast_visitor.js';
|
|
63
74
|
|
|
64
75
|
const jointDynamicsModifierSkeletons = new WeakMap();
|
|
76
|
+
const springModifierSkeletons = new WeakMap();
|
|
65
77
|
function encodeSkeletonBindPose(bindPose) {
|
|
66
78
|
return uint8ArrayToBase64(new Uint8Array(new Float32Array([
|
|
67
79
|
...bindPose.position,
|
|
@@ -87,6 +99,216 @@ function vectorToArray(value) {
|
|
|
87
99
|
function vectorFromArray(value, defaultValue = Vector3.zero()) {
|
|
88
100
|
return Array.isArray(value) ? new Vector3(value[0] ?? 0, value[1] ?? 0, value[2] ?? 0) : defaultValue.clone();
|
|
89
101
|
}
|
|
102
|
+
function quaternionToArray(value) {
|
|
103
|
+
return [
|
|
104
|
+
value.x,
|
|
105
|
+
value.y,
|
|
106
|
+
value.z,
|
|
107
|
+
value.w
|
|
108
|
+
];
|
|
109
|
+
}
|
|
110
|
+
function quaternionFromArray(value) {
|
|
111
|
+
return Array.isArray(value) ? new Quaternion(value[0] ?? 0, value[1] ?? 0, value[2] ?? 0, value[3] ?? 1) : undefined;
|
|
112
|
+
}
|
|
113
|
+
function serializeSpringChain(chain) {
|
|
114
|
+
return {
|
|
115
|
+
particles: chain.particles.map((particle)=>({
|
|
116
|
+
...particle.node ? {
|
|
117
|
+
node: particle.node.persistentId
|
|
118
|
+
} : {},
|
|
119
|
+
...particle.anchorNode ? {
|
|
120
|
+
anchorNode: particle.anchorNode.persistentId
|
|
121
|
+
} : {},
|
|
122
|
+
...particle.anchorOffset ? {
|
|
123
|
+
anchorOffset: vectorToArray(particle.anchorOffset)
|
|
124
|
+
} : {},
|
|
125
|
+
originalPosition: vectorToArray(particle.originalPosition),
|
|
126
|
+
...particle.originalRotation ? {
|
|
127
|
+
originalRotation: quaternionToArray(particle.originalRotation)
|
|
128
|
+
} : {},
|
|
129
|
+
mass: particle.mass,
|
|
130
|
+
damping: particle.damping,
|
|
131
|
+
fixed: particle.fixed
|
|
132
|
+
})),
|
|
133
|
+
constraints: chain.constraints.map((constraint)=>({
|
|
134
|
+
particleA: constraint.particleA,
|
|
135
|
+
particleB: constraint.particleB,
|
|
136
|
+
restLength: constraint.restLength,
|
|
137
|
+
stiffness: constraint.stiffness,
|
|
138
|
+
compliance: constraint.compliance
|
|
139
|
+
}))
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function deserializeSpringChain(ctx, data) {
|
|
143
|
+
const chain = new SpringChain();
|
|
144
|
+
for (const item of data.particles ?? []){
|
|
145
|
+
const node = findSerializedNode(ctx, item.node);
|
|
146
|
+
const anchorNode = findSerializedNode(ctx, item.anchorNode);
|
|
147
|
+
if (item.node && !node || item.anchorNode && !anchorNode) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
const position = node ? new Vector3(node.worldMatrix.m03, node.worldMatrix.m13, node.worldMatrix.m23) : vectorFromArray(item.originalPosition);
|
|
151
|
+
let originalRotation = quaternionFromArray(item.originalRotation);
|
|
152
|
+
if (node) {
|
|
153
|
+
originalRotation = new Quaternion();
|
|
154
|
+
node.worldMatrix.decompose(null, originalRotation, null);
|
|
155
|
+
}
|
|
156
|
+
chain.addParticle(createSpringParticle(position, {
|
|
157
|
+
mass: item.mass,
|
|
158
|
+
damping: item.damping,
|
|
159
|
+
fixed: item.fixed,
|
|
160
|
+
node: node ?? undefined,
|
|
161
|
+
anchorNode: anchorNode ?? undefined,
|
|
162
|
+
anchorOffset: item.anchorOffset ? vectorFromArray(item.anchorOffset) : undefined,
|
|
163
|
+
originalRotation
|
|
164
|
+
}));
|
|
165
|
+
}
|
|
166
|
+
for (const item of data.constraints ?? []){
|
|
167
|
+
if (item.particleA < 0 || item.particleB < 0 || item.particleA >= chain.particles.length || item.particleB >= chain.particles.length) {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
chain.addConstraint(createSpringConstraint(item.particleA, item.particleB, item.restLength, item.stiffness, item.compliance));
|
|
171
|
+
}
|
|
172
|
+
return chain.particles.length > 0 ? chain : null;
|
|
173
|
+
}
|
|
174
|
+
function serializeSpringCollider(collider) {
|
|
175
|
+
switch(collider.type){
|
|
176
|
+
case 'sphere':
|
|
177
|
+
{
|
|
178
|
+
const sphere = collider;
|
|
179
|
+
return {
|
|
180
|
+
type: 'sphere',
|
|
181
|
+
...sphere.node ? {
|
|
182
|
+
node: sphere.node.persistentId
|
|
183
|
+
} : {},
|
|
184
|
+
enabled: sphere.enabled,
|
|
185
|
+
center: vectorToArray(sphere.center),
|
|
186
|
+
radius: sphere.radius,
|
|
187
|
+
...sphere.localRadius !== undefined ? {
|
|
188
|
+
localRadius: sphere.localRadius
|
|
189
|
+
} : {},
|
|
190
|
+
...sphere.localRadiusScaleRef !== undefined ? {
|
|
191
|
+
localRadiusScaleRef: sphere.localRadiusScaleRef
|
|
192
|
+
} : {},
|
|
193
|
+
...sphere.localOffset ? {
|
|
194
|
+
localOffset: vectorToArray(sphere.localOffset)
|
|
195
|
+
} : {}
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
case 'capsule':
|
|
199
|
+
{
|
|
200
|
+
const capsule = collider;
|
|
201
|
+
return {
|
|
202
|
+
type: 'capsule',
|
|
203
|
+
...capsule.node ? {
|
|
204
|
+
node: capsule.node.persistentId
|
|
205
|
+
} : {},
|
|
206
|
+
enabled: capsule.enabled,
|
|
207
|
+
start: vectorToArray(capsule.start),
|
|
208
|
+
end: vectorToArray(capsule.end),
|
|
209
|
+
radius: capsule.radius,
|
|
210
|
+
...capsule.localRadius !== undefined ? {
|
|
211
|
+
localRadius: capsule.localRadius
|
|
212
|
+
} : {},
|
|
213
|
+
...capsule.localRadiusScaleRef !== undefined ? {
|
|
214
|
+
localRadiusScaleRef: capsule.localRadiusScaleRef
|
|
215
|
+
} : {},
|
|
216
|
+
...capsule.localStartOffset ? {
|
|
217
|
+
localStartOffset: vectorToArray(capsule.localStartOffset)
|
|
218
|
+
} : {},
|
|
219
|
+
...capsule.localEndOffset ? {
|
|
220
|
+
localEndOffset: vectorToArray(capsule.localEndOffset)
|
|
221
|
+
} : {}
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
case 'plane':
|
|
225
|
+
{
|
|
226
|
+
const plane = collider;
|
|
227
|
+
return {
|
|
228
|
+
type: 'plane',
|
|
229
|
+
...plane.node ? {
|
|
230
|
+
node: plane.node.persistentId
|
|
231
|
+
} : {},
|
|
232
|
+
enabled: plane.enabled,
|
|
233
|
+
point: vectorToArray(plane.point),
|
|
234
|
+
normal: vectorToArray(plane.normal),
|
|
235
|
+
...plane.localPointOffset ? {
|
|
236
|
+
localPointOffset: vectorToArray(plane.localPointOffset)
|
|
237
|
+
} : {},
|
|
238
|
+
...plane.localNormal ? {
|
|
239
|
+
localNormal: vectorToArray(plane.localNormal)
|
|
240
|
+
} : {}
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
function restoreSpringColliderRadiusScale(collider, data) {
|
|
246
|
+
const createdScaleRef = collider.localRadiusScaleRef;
|
|
247
|
+
if (data.localRadiusScaleRef !== undefined) {
|
|
248
|
+
collider.localRadiusScaleRef = data.localRadiusScaleRef;
|
|
249
|
+
} else if (data.localRadius !== undefined && createdScaleRef !== undefined && Number.isFinite(data.localRadius) && Number.isFinite(data.radius) && Math.abs(data.radius) > 1e-6) {
|
|
250
|
+
// Older serialized modifiers omitted the authored scale reference. Recover it
|
|
251
|
+
// from the stored world radius and the node scale captured by the constructor.
|
|
252
|
+
const inferredScaleRef = data.localRadius * createdScaleRef / data.radius;
|
|
253
|
+
if (Number.isFinite(inferredScaleRef) && Math.abs(inferredScaleRef) > 1e-6) {
|
|
254
|
+
collider.localRadiusScaleRef = Math.abs(inferredScaleRef);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
collider.radius = data.radius;
|
|
258
|
+
}
|
|
259
|
+
function deserializeSpringCollider(ctx, data) {
|
|
260
|
+
const node = findSerializedNode(ctx, data.node);
|
|
261
|
+
if (data.node && !node) {
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
264
|
+
let collider;
|
|
265
|
+
switch(data.type){
|
|
266
|
+
case 'sphere':
|
|
267
|
+
{
|
|
268
|
+
const sphere = createSphereCollider(node && data.localOffset ? vectorFromArray(data.localOffset) : vectorFromArray(data.center), node ? data.localRadius ?? data.radius : data.radius, node ?? undefined);
|
|
269
|
+
restoreSpringColliderRadiusScale(sphere, data);
|
|
270
|
+
collider = sphere;
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
case 'capsule':
|
|
274
|
+
{
|
|
275
|
+
const capsule = createCapsuleCollider(node && data.localStartOffset ? vectorFromArray(data.localStartOffset) : vectorFromArray(data.start), node && data.localEndOffset ? vectorFromArray(data.localEndOffset) : vectorFromArray(data.end), node ? data.localRadius ?? data.radius : data.radius, node ?? undefined);
|
|
276
|
+
restoreSpringColliderRadiusScale(capsule, data);
|
|
277
|
+
collider = capsule;
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
case 'plane':
|
|
281
|
+
collider = createPlaneCollider(node && data.localPointOffset ? vectorFromArray(data.localPointOffset) : vectorFromArray(data.point), node && data.localNormal ? vectorFromArray(data.localNormal) : vectorFromArray(data.normal), node ?? undefined);
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
284
|
+
collider.enabled = data.enabled;
|
|
285
|
+
return collider;
|
|
286
|
+
}
|
|
287
|
+
function getSpringSystemOptions(system) {
|
|
288
|
+
return {
|
|
289
|
+
iterations: system.iterations,
|
|
290
|
+
gravity: vectorToArray(system.gravity),
|
|
291
|
+
wind: vectorToArray(system.wind),
|
|
292
|
+
enableInertialForces: system.enableInertialForces,
|
|
293
|
+
centrifugalScale: system.centrifugalScale,
|
|
294
|
+
coriolisScale: system.coriolisScale,
|
|
295
|
+
solver: system.solver,
|
|
296
|
+
poseFollow: system.poseFollow,
|
|
297
|
+
poseFollowRoot: system.poseFollowRoot,
|
|
298
|
+
poseFollowTip: system.poseFollowTip,
|
|
299
|
+
poseFollowExponent: system.poseFollowExponent,
|
|
300
|
+
maxPoseOffset: system.maxPoseOffset,
|
|
301
|
+
maxPoseOffsetRoot: system.maxPoseOffsetRoot,
|
|
302
|
+
maxPoseOffsetTip: system.maxPoseOffsetTip
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
function deserializeSpringSystemOptions(options) {
|
|
306
|
+
return {
|
|
307
|
+
...options,
|
|
308
|
+
gravity: vectorFromArray(options.gravity, new Vector3(0, -9.8, 0)),
|
|
309
|
+
wind: vectorFromArray(options.wind)
|
|
310
|
+
};
|
|
311
|
+
}
|
|
90
312
|
function serializeScalarCurve(value) {
|
|
91
313
|
return {
|
|
92
314
|
mode: value.mode,
|
|
@@ -197,6 +419,12 @@ function setJointDynamicsModifierSkeleton(modifier, skeleton) {
|
|
|
197
419
|
function getJointDynamicsModifierSkeleton(modifier) {
|
|
198
420
|
return jointDynamicsModifierSkeletons.get(modifier) ?? null;
|
|
199
421
|
}
|
|
422
|
+
/** @internal */ function setSpringModifierSkeleton(modifier, skeleton) {
|
|
423
|
+
springModifierSkeletons.set(modifier, skeleton);
|
|
424
|
+
}
|
|
425
|
+
/** @internal */ function getSpringModifierSkeleton(modifier) {
|
|
426
|
+
return springModifierSkeletons.get(modifier) ?? null;
|
|
427
|
+
}
|
|
200
428
|
const jointDynamicsPropOptions = {
|
|
201
429
|
group: 'Joint Dynamics'
|
|
202
430
|
};
|
|
@@ -394,6 +622,135 @@ function createJointDynamicsCurveProp(name, key, label, description) {
|
|
|
394
622
|
}
|
|
395
623
|
};
|
|
396
624
|
*/ }
|
|
625
|
+
/** @internal */ function getSpringModifierClass() {
|
|
626
|
+
return {
|
|
627
|
+
ctor: SpringModifier,
|
|
628
|
+
name: 'SpringModifier',
|
|
629
|
+
createFunc (ctx, init) {
|
|
630
|
+
const skeleton = ctx.findSkeletonRigById(init.skeleton) ?? ctx.findSkeletonById(init.skeleton)?.rig ?? null;
|
|
631
|
+
if (!skeleton || !Array.isArray(init.chains) || init.chains.length === 0) {
|
|
632
|
+
return {
|
|
633
|
+
obj: null,
|
|
634
|
+
loadProps: false
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
const chains = init.chains.map((chain)=>deserializeSpringChain(ctx, chain));
|
|
638
|
+
if (chains.some((chain)=>!chain)) {
|
|
639
|
+
return {
|
|
640
|
+
obj: null,
|
|
641
|
+
loadProps: false
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
const options = deserializeSpringSystemOptions(init.options);
|
|
645
|
+
let system;
|
|
646
|
+
if (init.systemType === 'single') {
|
|
647
|
+
system = new SpringSystem(chains[0], options);
|
|
648
|
+
} else {
|
|
649
|
+
const multiChainSystem = new MultiChainSpringSystem(options);
|
|
650
|
+
for (const chain of chains){
|
|
651
|
+
multiChainSystem.addChain(chain);
|
|
652
|
+
}
|
|
653
|
+
for (const constraint of init.interChainConstraints ?? []){
|
|
654
|
+
if (constraint.chainAIndex < 0 || constraint.chainBIndex < 0 || constraint.chainAIndex >= chains.length || constraint.chainBIndex >= chains.length) {
|
|
655
|
+
continue;
|
|
656
|
+
}
|
|
657
|
+
multiChainSystem.addInterChainConstraint({
|
|
658
|
+
...constraint,
|
|
659
|
+
lambda: 0
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
system = multiChainSystem;
|
|
663
|
+
}
|
|
664
|
+
for (const colliderData of init.colliders ?? []){
|
|
665
|
+
const collider = deserializeSpringCollider(ctx, colliderData);
|
|
666
|
+
if (collider) {
|
|
667
|
+
system.addCollider(collider);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
const modifier = new SpringModifier(system, init.weight ?? 1);
|
|
671
|
+
modifier.sourceId = init.sourceId ?? '';
|
|
672
|
+
modifier.enabled = init.enabled ?? true;
|
|
673
|
+
setSpringModifierSkeleton(modifier, skeleton);
|
|
674
|
+
return {
|
|
675
|
+
obj: modifier,
|
|
676
|
+
loadProps: false
|
|
677
|
+
};
|
|
678
|
+
},
|
|
679
|
+
getInitParams (obj) {
|
|
680
|
+
const skeleton = getSpringModifierSkeleton(obj);
|
|
681
|
+
const system = obj.springSystem;
|
|
682
|
+
const isMultiChain = system instanceof MultiChainSpringSystem;
|
|
683
|
+
if (!isMultiChain && !(system instanceof SpringSystem)) {
|
|
684
|
+
throw new Error('Serialize SpringModifier failed: Unsupported spring system type');
|
|
685
|
+
}
|
|
686
|
+
const chains = isMultiChain ? system.chains : [
|
|
687
|
+
system.chain
|
|
688
|
+
];
|
|
689
|
+
const init = {
|
|
690
|
+
skeleton: skeleton?.persistentId ?? '',
|
|
691
|
+
sourceId: obj.sourceId,
|
|
692
|
+
systemType: isMultiChain ? 'multi' : 'single',
|
|
693
|
+
options: getSpringSystemOptions(system),
|
|
694
|
+
chains: chains.map(serializeSpringChain),
|
|
695
|
+
...isMultiChain ? {
|
|
696
|
+
interChainConstraints: system.interChainConstraints.map(({ lambda: _lambda, ...constraint })=>constraint)
|
|
697
|
+
} : {},
|
|
698
|
+
colliders: system.colliders.map(serializeSpringCollider),
|
|
699
|
+
enabled: obj.enabled,
|
|
700
|
+
weight: obj.weight
|
|
701
|
+
};
|
|
702
|
+
return init;
|
|
703
|
+
},
|
|
704
|
+
getProps () {
|
|
705
|
+
return defineProps([
|
|
706
|
+
{
|
|
707
|
+
name: 'Commands',
|
|
708
|
+
description: 'Reset spring modifier state',
|
|
709
|
+
type: 'command',
|
|
710
|
+
command () {
|
|
711
|
+
this.reset();
|
|
712
|
+
return false;
|
|
713
|
+
},
|
|
714
|
+
get (value) {
|
|
715
|
+
value.str[0] = 'Reset';
|
|
716
|
+
}
|
|
717
|
+
},
|
|
718
|
+
{
|
|
719
|
+
name: 'Enabled',
|
|
720
|
+
description: 'Whether this spring modifier is active',
|
|
721
|
+
type: 'bool',
|
|
722
|
+
isPersistent () {
|
|
723
|
+
return false;
|
|
724
|
+
},
|
|
725
|
+
get (value) {
|
|
726
|
+
value.bool[0] = this.enabled;
|
|
727
|
+
},
|
|
728
|
+
set (value) {
|
|
729
|
+
this.enabled = value.bool[0];
|
|
730
|
+
}
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
name: 'Weight',
|
|
734
|
+
description: 'Physics blend weight. 0 uses animation only, 1 uses full spring physics',
|
|
735
|
+
type: 'float',
|
|
736
|
+
options: {
|
|
737
|
+
minValue: 0,
|
|
738
|
+
maxValue: 1
|
|
739
|
+
},
|
|
740
|
+
isPersistent () {
|
|
741
|
+
return false;
|
|
742
|
+
},
|
|
743
|
+
get (value) {
|
|
744
|
+
value.num[0] = this.weight;
|
|
745
|
+
},
|
|
746
|
+
set (value) {
|
|
747
|
+
this.weight = value.num[0];
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
]);
|
|
751
|
+
}
|
|
752
|
+
};
|
|
753
|
+
}
|
|
397
754
|
/** @internal */ function getJointDynamicsModifierClass() {
|
|
398
755
|
return {
|
|
399
756
|
ctor: JointDynamicsModifier,
|
|
@@ -410,9 +767,15 @@ function createJointDynamicsCurveProp(name, key, label, description) {
|
|
|
410
767
|
const chains = (init.chains ?? []).map((chain)=>{
|
|
411
768
|
const start = findSerializedNode(ctx, chain.start);
|
|
412
769
|
const end = findSerializedNode(ctx, chain.end);
|
|
770
|
+
const startAnchor = findSerializedNode(ctx, chain.startAnchor);
|
|
771
|
+
const endAnchor = findSerializedNode(ctx, chain.endAnchor);
|
|
413
772
|
return start && end ? {
|
|
414
773
|
start,
|
|
415
|
-
end
|
|
774
|
+
end,
|
|
775
|
+
startAnchor: startAnchor ?? undefined,
|
|
776
|
+
endAnchor: endAnchor ?? undefined,
|
|
777
|
+
startAnchorOffset: chain.startAnchorOffset ? vectorFromArray(chain.startAnchorOffset) : undefined,
|
|
778
|
+
endAnchorOffset: chain.endAnchorOffset ? vectorFromArray(chain.endAnchorOffset) : undefined
|
|
416
779
|
} : null;
|
|
417
780
|
}).filter((chain)=>{
|
|
418
781
|
return !!chain && chain.start.isParentOf(chain.end);
|
|
@@ -488,7 +851,11 @@ function createJointDynamicsCurveProp(name, key, label, description) {
|
|
|
488
851
|
systemRoot: chainConfig.systemRoot.persistentId,
|
|
489
852
|
chains: chainConfig.chains.map((chain)=>({
|
|
490
853
|
start: chain.start.persistentId,
|
|
491
|
-
end: chain.end.persistentId
|
|
854
|
+
end: chain.end.persistentId,
|
|
855
|
+
startAnchor: chain.startAnchor?.persistentId,
|
|
856
|
+
endAnchor: chain.endAnchor?.persistentId,
|
|
857
|
+
startAnchorOffset: chain.startAnchorOffset ? vectorToArray(chain.startAnchorOffset) : undefined,
|
|
858
|
+
endAnchorOffset: chain.endAnchorOffset ? vectorToArray(chain.endAnchorOffset) : undefined
|
|
492
859
|
})),
|
|
493
860
|
controllerConfig: serializeControllerConfig(controllerConfig),
|
|
494
861
|
colliders: obj.jointDynamicsSystem.getColliderSnapshots().map((item)=>({
|
|
@@ -1792,5 +2159,5 @@ function getPCAGeometryCacheTrackClass() {
|
|
|
1792
2159
|
};
|
|
1793
2160
|
}
|
|
1794
2161
|
|
|
1795
|
-
export { getAnimationClass, getFixedGeometryCacheTrackClass, getInterpolatorClass, getInterpolatorScalarClass, getJointDynamicsModifierClass, getJointDynamicsModifierSkeleton, getMorphTargetGroupTrackClass, getMorphTrackClass, getNodeEulerRotationTrackClass, getNodeRotationTrackClass, getNodeScaleTrackClass, getNodeTranslationTrackClass, getPCAGeometryCacheTrackClass, getPropTrackClass, getSkeletonClass, getSkeletonRigClass, getSkinBindingClass, setJointDynamicsModifierSkeleton };
|
|
2162
|
+
export { getAnimationClass, getFixedGeometryCacheTrackClass, getInterpolatorClass, getInterpolatorScalarClass, getJointDynamicsModifierClass, getJointDynamicsModifierSkeleton, getMorphTargetGroupTrackClass, getMorphTrackClass, getNodeEulerRotationTrackClass, getNodeRotationTrackClass, getNodeScaleTrackClass, getNodeTranslationTrackClass, getPCAGeometryCacheTrackClass, getPropTrackClass, getSkeletonClass, getSkeletonRigClass, getSkinBindingClass, getSpringModifierClass, getSpringModifierSkeleton, setJointDynamicsModifierSkeleton, setSpringModifierSkeleton };
|
|
1796
2163
|
//# sourceMappingURL=animation.js.map
|