@zephyr3d/scene 0.3.1 → 0.5.0
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/animation.js +25 -117
- package/dist/animation/animation.js.map +1 -1
- package/dist/animation/animationset.js +164 -24
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/animationtrack.js +6 -18
- package/dist/animation/animationtrack.js.map +1 -1
- package/dist/animation/eulerrotationtrack.js +16 -6
- package/dist/animation/eulerrotationtrack.js.map +1 -1
- package/dist/animation/morphtarget.js +104 -0
- package/dist/animation/morphtarget.js.map +1 -0
- package/dist/animation/morphtrack.js +68 -0
- package/dist/animation/morphtrack.js.map +1 -0
- package/dist/animation/rotationtrack.js +15 -7
- package/dist/animation/rotationtrack.js.map +1 -1
- package/dist/animation/scaletrack.js +15 -7
- package/dist/animation/scaletrack.js.map +1 -1
- package/dist/animation/skeleton.js +101 -1
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/translationtrack.js +15 -7
- package/dist/animation/translationtrack.js.map +1 -1
- package/dist/animation/usertrack.js +2 -2
- package/dist/app.js +4 -26
- package/dist/app.js.map +1 -1
- package/dist/asset/assetmanager.js +58 -107
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/loaders/dds/dds.js +77 -3
- package/dist/asset/loaders/dds/dds.js.map +1 -1
- package/dist/asset/loaders/dds/dds_loader.js +1 -1
- package/dist/asset/loaders/gltf/gltf_loader.js +284 -45
- package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -1
- package/dist/asset/loaders/image/tga_Loader.js +1 -1
- package/dist/asset/model.js +13 -0
- package/dist/asset/model.js.map +1 -1
- package/dist/blitter/blitter.js +2 -2
- package/dist/camera/camera.js +83 -5
- package/dist/camera/camera.js.map +1 -1
- package/dist/index.d.ts +5212 -4785
- package/dist/index.js +6 -7
- package/dist/index.js.map +1 -1
- package/dist/material/blinn.js +9 -4
- package/dist/material/blinn.js.map +1 -1
- package/dist/material/grassmat.js +127 -0
- package/dist/material/grassmat.js.map +1 -0
- package/dist/material/grassmaterial.js +15 -0
- package/dist/material/grassmaterial.js.map +1 -1
- package/dist/material/lambert.js +22 -17
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/lightmodel.js +7 -6
- package/dist/material/lightmodel.js.map +1 -1
- package/dist/material/lit.js +99 -5
- package/dist/material/lit.js.map +1 -1
- package/dist/material/material.js +88 -347
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +122 -102
- package/dist/material/meshmaterial.js.map +1 -1
- package/dist/material/mixins/albedocolor.js +11 -3
- package/dist/material/mixins/albedocolor.js.map +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +3 -3
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +3 -3
- package/dist/material/mixins/lit.js +2 -2
- package/dist/material/mixins/pbr/common.js +433 -10
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/pbrmr.js +17 -6
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/pbrsg.js +16 -9
- package/dist/material/pbrsg.js.map +1 -1
- package/dist/material/shader/helper.js +186 -117
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/terrainlightmodel.js +3 -1
- package/dist/material/terrainlightmodel.js.map +1 -1
- package/dist/material/terrainmat.js +357 -0
- package/dist/material/terrainmat.js.map +1 -0
- package/dist/material/terrainmaterial.js +16 -0
- package/dist/material/terrainmaterial.js.map +1 -1
- package/dist/material/unlit.js +8 -4
- package/dist/material/unlit.js.map +1 -1
- package/dist/posteffect/bloom.js +34 -45
- package/dist/posteffect/bloom.js.map +1 -1
- package/dist/posteffect/compositor.js +11 -41
- package/dist/posteffect/compositor.js.map +1 -1
- package/dist/posteffect/fxaa.js +1 -2
- package/dist/posteffect/fxaa.js.map +1 -1
- package/dist/posteffect/grayscale.js +1 -2
- package/dist/posteffect/grayscale.js.map +1 -1
- package/dist/posteffect/posteffect.js +0 -74
- package/dist/posteffect/posteffect.js.map +1 -1
- package/dist/posteffect/sao.js +13 -29
- package/dist/posteffect/sao.js.map +1 -1
- package/dist/posteffect/tonemap.js +1 -2
- package/dist/posteffect/tonemap.js.map +1 -1
- package/dist/posteffect/water.js +20 -18
- package/dist/posteffect/water.js.map +1 -1
- package/dist/render/abuffer_oit.js +352 -0
- package/dist/render/abuffer_oit.js.map +1 -0
- package/dist/render/cull_visitor.js +3 -3
- package/dist/render/depth_pass.js +3 -2
- package/dist/render/depth_pass.js.map +1 -1
- package/dist/render/depthpass.js +16 -19
- package/dist/render/depthpass.js.map +1 -1
- package/dist/render/drawable_mixin.js +152 -0
- package/dist/render/drawable_mixin.js.map +1 -0
- package/dist/render/envlight.js +165 -31
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/forward.js +3 -6
- package/dist/render/forward.js.map +1 -1
- package/dist/render/forward_pass.js +6 -5
- package/dist/render/forward_pass.js.map +1 -1
- package/dist/render/globalbindgroup_allocator.js +58 -0
- package/dist/render/globalbindgroup_allocator.js.map +1 -0
- package/dist/render/lightpass.js +83 -49
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/objectcolorpass.js +50 -0
- package/dist/render/objectcolorpass.js.map +1 -0
- package/dist/render/objectpool.js +295 -0
- package/dist/render/objectpool.js.map +1 -0
- package/dist/render/oit.js +16 -0
- package/dist/render/oit.js.map +1 -0
- package/dist/render/render_queue.js +294 -107
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/renderbundle_wrapper.js +20 -0
- package/dist/render/renderbundle_wrapper.js.map +1 -0
- package/dist/render/renderer.js +108 -28
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/renderpass.js +96 -34
- package/dist/render/renderpass.js.map +1 -1
- package/dist/render/shadowmap_pass.js +18 -37
- package/dist/render/shadowmap_pass.js.map +1 -1
- package/dist/render/sky.js +2 -2
- package/dist/render/watermesh.js +140 -48
- package/dist/render/watermesh.js.map +1 -1
- package/dist/render/weightedblended_oit.js +171 -0
- package/dist/render/weightedblended_oit.js.map +1 -0
- package/dist/scene/batchgroup.js +8 -35
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +24 -4
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/graph_node.js +1 -10
- package/dist/scene/graph_node.js.map +1 -1
- package/dist/scene/mesh.js +42 -32
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/scene.js +7 -37
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +6 -2
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/terrain/grass.js +26 -11
- package/dist/scene/terrain/grass.js.map +1 -1
- package/dist/scene/terrain/patch.js +27 -15
- package/dist/scene/terrain/patch.js.map +1 -1
- package/dist/scene/terrain/quadtree.js +3 -3
- package/dist/scene/terrain/terrain.js +0 -8
- package/dist/scene/terrain/terrain.js.map +1 -1
- package/dist/shaders/lighting.js +14 -10
- package/dist/shaders/lighting.js.map +1 -1
- package/dist/shaders/water.js +4 -4
- package/dist/shadow/esm.js +4 -23
- package/dist/shadow/esm.js.map +1 -1
- package/dist/shadow/shadowmapper.js +45 -21
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shadow/vsm.js +4 -25
- package/dist/shadow/vsm.js.map +1 -1
- package/dist/utility/draco/decoder.js +116 -0
- package/dist/utility/draco/decoder.js.map +1 -0
- package/dist/utility/sheenlut.js +196 -0
- package/dist/utility/sheenlut.js.map +1 -0
- package/dist/values.js +18 -1
- package/dist/values.js.map +1 -1
- package/package.json +7 -6
- package/dist/utility/noisetexture.js +0 -66
- package/dist/utility/noisetexture.js.map +0 -1
- package/dist/utility/textures/gradientnoise.js +0 -66
- package/dist/utility/textures/gradientnoise.js.map +0 -1
- package/dist/utility/textures/randomnoise.js +0 -41
- package/dist/utility/textures/randomnoise.js.map +0 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { AnimationTrack } from './animationtrack.js';
|
|
2
|
+
import '../utility/pmrem.js';
|
|
3
|
+
import '../utility/panorama.js';
|
|
4
|
+
import '../utility/shprojection.js';
|
|
5
|
+
import { Vector3 } from '@zephyr3d/base';
|
|
6
|
+
import { BoundingBox } from '../utility/bounding_volume.js';
|
|
7
|
+
import { MAX_MORPH_TARGETS } from '../values.js';
|
|
8
|
+
import { calculateMorphBoundingBox } from './morphtarget.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Morph target track
|
|
12
|
+
* @public
|
|
13
|
+
*/ class MorphTargetTrack extends AnimationTrack {
|
|
14
|
+
_state;
|
|
15
|
+
_boundingBox;
|
|
16
|
+
_defaultWeights;
|
|
17
|
+
/**
|
|
18
|
+
* Create an instance of MorphTargetTrack
|
|
19
|
+
*/ constructor(assetTrack, subMesh){
|
|
20
|
+
super(assetTrack.interpolator);
|
|
21
|
+
this._state = {
|
|
22
|
+
numTargets: assetTrack.interpolator.stride,
|
|
23
|
+
boundingBox: new BoundingBox(),
|
|
24
|
+
weights: new Float32Array(MAX_MORPH_TARGETS)
|
|
25
|
+
};
|
|
26
|
+
this._boundingBox = subMesh.targetBox;
|
|
27
|
+
this._defaultWeights = assetTrack.defaultMorphWeights ?? Array.from({
|
|
28
|
+
length: this._state.numTargets
|
|
29
|
+
}).map(()=>0);
|
|
30
|
+
}
|
|
31
|
+
calculateState(currentTime) {
|
|
32
|
+
this._interpolator.interpolate(currentTime, this._state.weights);
|
|
33
|
+
calculateMorphBoundingBox(this._state.boundingBox, this._boundingBox, this._state.weights, this._state.numTargets);
|
|
34
|
+
return this._state;
|
|
35
|
+
}
|
|
36
|
+
applyState(node, state) {
|
|
37
|
+
node.getMorphInfo().bufferSubData(4 * 4, state.weights);
|
|
38
|
+
const animatedBoundingBox = new BoundingBox();
|
|
39
|
+
const originBoundingBox = node.getBoundingVolume().toAABB();
|
|
40
|
+
animatedBoundingBox.minPoint = Vector3.add(originBoundingBox.minPoint, state.boundingBox.minPoint);
|
|
41
|
+
animatedBoundingBox.maxPoint = Vector3.add(originBoundingBox.maxPoint, state.boundingBox.maxPoint);
|
|
42
|
+
node.setAnimatedBoundingBox(animatedBoundingBox);
|
|
43
|
+
}
|
|
44
|
+
mixState(a, b, t) {
|
|
45
|
+
const state = {
|
|
46
|
+
weights: new Float32Array(a.numTargets),
|
|
47
|
+
boundingBox: new BoundingBox(),
|
|
48
|
+
numTargets: a.numTargets
|
|
49
|
+
};
|
|
50
|
+
for(let i = 0; i < a.numTargets; i++){
|
|
51
|
+
state.weights[i] = a.weights[i] + (b.weights[i] - a.weights[i]) * t;
|
|
52
|
+
state.boundingBox.minPoint = Vector3.min(a.boundingBox.minPoint, b.boundingBox.minPoint);
|
|
53
|
+
state.boundingBox.maxPoint = Vector3.max(a.boundingBox.maxPoint, b.boundingBox.maxPoint);
|
|
54
|
+
}
|
|
55
|
+
return state;
|
|
56
|
+
}
|
|
57
|
+
getBlendId() {
|
|
58
|
+
return 'node-morph';
|
|
59
|
+
}
|
|
60
|
+
reset(node) {
|
|
61
|
+
// apply default weights
|
|
62
|
+
this._state.weights.set(this._defaultWeights);
|
|
63
|
+
this.applyState(node, this._state);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export { MorphTargetTrack };
|
|
68
|
+
//# sourceMappingURL=morphtrack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"morphtrack.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Interpolator, Quaternion } from '@zephyr3d/base';
|
|
2
2
|
import { AnimationTrack } from './animationtrack.js';
|
|
3
3
|
|
|
4
|
-
// Reduce gc
|
|
5
|
-
const tmpQuat = new Quaternion();
|
|
6
4
|
/**
|
|
7
5
|
* Rotation animation track
|
|
8
6
|
* @public
|
|
9
7
|
*/ class RotationTrack extends AnimationTrack {
|
|
8
|
+
_state;
|
|
10
9
|
constructor(modeOrInterpolator, keyFrames){
|
|
11
10
|
if (modeOrInterpolator instanceof Interpolator) {
|
|
12
11
|
if (modeOrInterpolator.target !== 'quat') {
|
|
@@ -25,11 +24,20 @@ const tmpQuat = new Quaternion();
|
|
|
25
24
|
const interpolator = new Interpolator(modeOrInterpolator, 'quat', inputs, outputs);
|
|
26
25
|
super(interpolator);
|
|
27
26
|
}
|
|
27
|
+
this._state = new Quaternion();
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
this._interpolator.interpolate(currentTime,
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
calculateState(currentTime) {
|
|
30
|
+
this._interpolator.interpolate(currentTime, this._state);
|
|
31
|
+
return this._state;
|
|
32
|
+
}
|
|
33
|
+
applyState(node, state) {
|
|
34
|
+
node.rotation.set(state);
|
|
35
|
+
}
|
|
36
|
+
mixState(a, b, t) {
|
|
37
|
+
return Quaternion.slerp(a, b, t);
|
|
38
|
+
}
|
|
39
|
+
getBlendId() {
|
|
40
|
+
return 'node-rotation';
|
|
33
41
|
}
|
|
34
42
|
}
|
|
35
43
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rotationtrack.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rotationtrack.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Interpolator, Vector3 } from '@zephyr3d/base';
|
|
2
2
|
import { AnimationTrack } from './animationtrack.js';
|
|
3
3
|
|
|
4
|
-
// Reduce gc
|
|
5
|
-
const tmpVec3 = new Vector3();
|
|
6
4
|
/**
|
|
7
5
|
* Scale animation track
|
|
8
6
|
* @public
|
|
9
7
|
*/ class ScaleTrack extends AnimationTrack {
|
|
8
|
+
_state;
|
|
10
9
|
constructor(modeOrInterpolator, keyFrames){
|
|
11
10
|
if (modeOrInterpolator instanceof Interpolator) {
|
|
12
11
|
if (modeOrInterpolator.target !== 'vec3') {
|
|
@@ -24,11 +23,20 @@ const tmpVec3 = new Vector3();
|
|
|
24
23
|
const interpolator = new Interpolator(modeOrInterpolator, 'vec3', inputs, outputs);
|
|
25
24
|
super(interpolator);
|
|
26
25
|
}
|
|
26
|
+
this._state = new Vector3();
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
this._interpolator.interpolate(currentTime,
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
calculateState(currentTime) {
|
|
29
|
+
this._interpolator.interpolate(currentTime, this._state);
|
|
30
|
+
return this._state;
|
|
31
|
+
}
|
|
32
|
+
applyState(node, state) {
|
|
33
|
+
node.scale.set(state);
|
|
34
|
+
}
|
|
35
|
+
mixState(a, b, t) {
|
|
36
|
+
return new Vector3(a.x + t * (b.x - a.x), a.y + t * (b.y - a.y), a.z + t * (b.z - a.z));
|
|
37
|
+
}
|
|
38
|
+
getBlendId() {
|
|
39
|
+
return 'node-scale';
|
|
32
40
|
}
|
|
33
41
|
}
|
|
34
42
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scaletrack.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scaletrack.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { Vector3, Matrix4x4, nextPowerOf2 } from '@zephyr3d/base';
|
|
2
2
|
import { Application } from '../app.js';
|
|
3
|
+
import '../utility/pmrem.js';
|
|
4
|
+
import '../utility/panorama.js';
|
|
5
|
+
import '../utility/shprojection.js';
|
|
6
|
+
import { BoundingBox } from '../utility/bounding_volume.js';
|
|
3
7
|
|
|
4
8
|
const tmpV0 = new Vector3();
|
|
5
9
|
const tmpV1 = new Vector3();
|
|
@@ -9,6 +13,7 @@ const tmpV3 = new Vector3();
|
|
|
9
13
|
* Skeleton for skinned animation
|
|
10
14
|
* @public
|
|
11
15
|
*/ class Skeleton {
|
|
16
|
+
/** @internal */ _meshes;
|
|
12
17
|
/** @internal */ _joints;
|
|
13
18
|
/** @internal */ _inverseBindMatrices;
|
|
14
19
|
/** @internal */ _bindPoseMatrices;
|
|
@@ -20,13 +25,21 @@ const tmpV3 = new Vector3();
|
|
|
20
25
|
* @param joints - The joint nodes
|
|
21
26
|
* @param inverseBindMatrices - The inverse binding matrices of the joints
|
|
22
27
|
* @param bindPoseMatrices - The binding pose matrices of the joints
|
|
23
|
-
*/ constructor(joints, inverseBindMatrices, bindPoseMatrices){
|
|
28
|
+
*/ constructor(joints, inverseBindMatrices, bindPoseMatrices, meshes, bounding){
|
|
24
29
|
this._joints = joints;
|
|
25
30
|
this._inverseBindMatrices = inverseBindMatrices;
|
|
26
31
|
this._bindPoseMatrices = bindPoseMatrices;
|
|
27
32
|
this._jointMatrixArray = null;
|
|
28
33
|
this._jointMatrices = null;
|
|
29
34
|
this._jointTexture = null;
|
|
35
|
+
this.updateJointMatrices();
|
|
36
|
+
this._meshes = meshes.map((mesh, index)=>{
|
|
37
|
+
return {
|
|
38
|
+
mesh,
|
|
39
|
+
bounding: this.getBoundingInfo(bounding[index]),
|
|
40
|
+
box: new BoundingBox()
|
|
41
|
+
};
|
|
42
|
+
});
|
|
30
43
|
}
|
|
31
44
|
/**
|
|
32
45
|
* Disposes self
|
|
@@ -66,6 +79,25 @@ const tmpV3 = new Vector3();
|
|
|
66
79
|
this.updateJointMatrices();
|
|
67
80
|
this._jointTexture.update(this._jointMatrixArray, 0, 0, this._jointTexture.width, this._jointTexture.height);
|
|
68
81
|
}
|
|
82
|
+
/** @internal */ apply() {
|
|
83
|
+
this.computeJoints();
|
|
84
|
+
for (const mesh of this._meshes){
|
|
85
|
+
this.computeBoundingBox(mesh.bounding, mesh.mesh.invWorldMatrix);
|
|
86
|
+
mesh.mesh.setBoneMatrices(this.jointTexture);
|
|
87
|
+
mesh.mesh.setInvBindMatrix(mesh.mesh.invWorldMatrix);
|
|
88
|
+
mesh.mesh.setAnimatedBoundingBox(mesh.bounding.boundingBox);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/** @internal */ reset(model) {
|
|
92
|
+
this.computeBindPose();
|
|
93
|
+
for (const mesh of this._meshes){
|
|
94
|
+
const invWorldMatrix = Matrix4x4.multiply(mesh.mesh.invWorldMatrix, model.worldMatrix);
|
|
95
|
+
this.computeBoundingBox(mesh.bounding, invWorldMatrix);
|
|
96
|
+
mesh.mesh.setBoneMatrices(this.jointTexture);
|
|
97
|
+
mesh.mesh.setInvBindMatrix(invWorldMatrix);
|
|
98
|
+
mesh.mesh.setAnimatedBoundingBox(mesh.bounding.boundingBox);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
69
101
|
/** @internal */ computeBoundingBox(info, invWorldMatrix) {
|
|
70
102
|
info.boundingBox.beginExtend();
|
|
71
103
|
for(let i = 0; i < info.boundingVertices.length; i++){
|
|
@@ -91,6 +123,74 @@ const tmpV3 = new Vector3();
|
|
|
91
123
|
const buffer = this._jointMatrixArray.buffer;
|
|
92
124
|
this._jointMatrices = this._joints.map((val, index)=>new Matrix4x4(buffer, index * 16 * Float32Array.BYTES_PER_ELEMENT));
|
|
93
125
|
}
|
|
126
|
+
/** @internal */ getBoundingInfo(meshData) {
|
|
127
|
+
const indices = [
|
|
128
|
+
0,
|
|
129
|
+
0,
|
|
130
|
+
0,
|
|
131
|
+
0,
|
|
132
|
+
0,
|
|
133
|
+
0
|
|
134
|
+
];
|
|
135
|
+
let minx = Number.MAX_VALUE;
|
|
136
|
+
let maxx = -Number.MAX_VALUE;
|
|
137
|
+
let miny = Number.MAX_VALUE;
|
|
138
|
+
let maxy = -Number.MAX_VALUE;
|
|
139
|
+
let minz = Number.MAX_VALUE;
|
|
140
|
+
let maxz = -Number.MAX_VALUE;
|
|
141
|
+
const v = meshData.rawPositions;
|
|
142
|
+
const vert = new Vector3();
|
|
143
|
+
const tmpV0 = new Vector3();
|
|
144
|
+
const tmpV1 = new Vector3();
|
|
145
|
+
const tmpV2 = new Vector3();
|
|
146
|
+
const tmpV3 = new Vector3();
|
|
147
|
+
const numVertices = Math.floor(v.length / 3);
|
|
148
|
+
for(let i = 0; i < numVertices; i++){
|
|
149
|
+
vert.setXYZ(v[i * 3], v[i * 3 + 1], v[i * 3 + 2]);
|
|
150
|
+
this.jointMatrices[meshData.rawBlendIndices[i * 4 + 0]].transformPointAffine(vert, tmpV0).scaleBy(meshData.rawJointWeights[i * 4 + 0]);
|
|
151
|
+
this.jointMatrices[meshData.rawBlendIndices[i * 4 + 1]].transformPointAffine(vert, tmpV1).scaleBy(meshData.rawJointWeights[i * 4 + 1]);
|
|
152
|
+
this.jointMatrices[meshData.rawBlendIndices[i * 4 + 2]].transformPointAffine(vert, tmpV2).scaleBy(meshData.rawJointWeights[i * 4 + 2]);
|
|
153
|
+
this.jointMatrices[meshData.rawBlendIndices[i * 4 + 3]].transformPointAffine(vert, tmpV3).scaleBy(meshData.rawJointWeights[i * 4 + 3]);
|
|
154
|
+
tmpV0.addBy(tmpV1).addBy(tmpV2).addBy(tmpV3);
|
|
155
|
+
if (tmpV0.x < minx) {
|
|
156
|
+
minx = tmpV0.x;
|
|
157
|
+
indices[0] = i;
|
|
158
|
+
}
|
|
159
|
+
if (tmpV0.x > maxx) {
|
|
160
|
+
maxx = tmpV0.x;
|
|
161
|
+
indices[1] = i;
|
|
162
|
+
}
|
|
163
|
+
if (tmpV0.y < miny) {
|
|
164
|
+
miny = tmpV0.y;
|
|
165
|
+
indices[2] = i;
|
|
166
|
+
}
|
|
167
|
+
if (tmpV0.y > maxy) {
|
|
168
|
+
maxy = tmpV0.y;
|
|
169
|
+
indices[3] = i;
|
|
170
|
+
}
|
|
171
|
+
if (tmpV0.z < minz) {
|
|
172
|
+
minz = tmpV0.z;
|
|
173
|
+
indices[4] = i;
|
|
174
|
+
}
|
|
175
|
+
if (tmpV0.z > maxz) {
|
|
176
|
+
maxz = tmpV0.z;
|
|
177
|
+
indices[5] = i;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const info = {
|
|
181
|
+
boundingVertexBlendIndices: new Float32Array(Array.from({
|
|
182
|
+
length: 6 * 4
|
|
183
|
+
}).map((val, index)=>meshData.rawBlendIndices[indices[index >> 2] * 4 + index % 4])),
|
|
184
|
+
boundingVertexJointWeights: new Float32Array(Array.from({
|
|
185
|
+
length: 6 * 4
|
|
186
|
+
}).map((val, index)=>meshData.rawJointWeights[indices[index >> 2] * 4 + index % 4])),
|
|
187
|
+
boundingVertices: Array.from({
|
|
188
|
+
length: 6
|
|
189
|
+
}).map((val, index)=>new Vector3(meshData.rawPositions[indices[index] * 3], meshData.rawPositions[indices[index] * 3 + 1], meshData.rawPositions[indices[index] * 3 + 2])),
|
|
190
|
+
boundingBox: new BoundingBox()
|
|
191
|
+
};
|
|
192
|
+
return info;
|
|
193
|
+
}
|
|
94
194
|
}
|
|
95
195
|
|
|
96
196
|
export { Skeleton };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skeleton.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"skeleton.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Interpolator, Vector3 } from '@zephyr3d/base';
|
|
2
2
|
import { AnimationTrack } from './animationtrack.js';
|
|
3
3
|
|
|
4
|
-
// Reduce gc
|
|
5
|
-
const tmpVec3 = new Vector3();
|
|
6
4
|
/**
|
|
7
5
|
* Translate animation track
|
|
8
6
|
* @public
|
|
9
7
|
*/ class TranslationTrack extends AnimationTrack {
|
|
8
|
+
_state;
|
|
10
9
|
constructor(modeOrInterpolator, keyFrames){
|
|
11
10
|
if (modeOrInterpolator instanceof Interpolator) {
|
|
12
11
|
if (modeOrInterpolator.target !== 'vec3') {
|
|
@@ -24,11 +23,20 @@ const tmpVec3 = new Vector3();
|
|
|
24
23
|
const interpolator = new Interpolator(modeOrInterpolator, 'vec3', inputs, outputs);
|
|
25
24
|
super(interpolator);
|
|
26
25
|
}
|
|
26
|
+
this._state = new Vector3();
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
this._interpolator.interpolate(currentTime,
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
calculateState(currentTime) {
|
|
29
|
+
this._interpolator.interpolate(currentTime, this._state);
|
|
30
|
+
return this._state;
|
|
31
|
+
}
|
|
32
|
+
applyState(node, state) {
|
|
33
|
+
node.position.set(state);
|
|
34
|
+
}
|
|
35
|
+
mixState(a, b, t) {
|
|
36
|
+
return new Vector3(a.x + t * (b.x - a.x), a.y + t * (b.y - a.y), a.z + t * (b.z - a.z));
|
|
37
|
+
}
|
|
38
|
+
getBlendId() {
|
|
39
|
+
return 'node-translation';
|
|
32
40
|
}
|
|
33
41
|
}
|
|
34
42
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translationtrack.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"translationtrack.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -36,8 +36,8 @@ const tmpValue = new Float32Array(4);
|
|
|
36
36
|
super(interpolator);
|
|
37
37
|
this._handler = handler;
|
|
38
38
|
}
|
|
39
|
-
/** {@inheritDoc AnimationTrack.apply} */ apply(node, currentTime
|
|
40
|
-
this._interpolator.interpolate(currentTime,
|
|
39
|
+
/** {@inheritDoc AnimationTrack.apply} */ apply(node, currentTime) {
|
|
40
|
+
this._interpolator.interpolate(currentTime, tmpValue);
|
|
41
41
|
this._handler && this._handler(node, tmpValue);
|
|
42
42
|
return true;
|
|
43
43
|
}
|
package/dist/app.js
CHANGED
|
@@ -39,9 +39,7 @@ import { makeEventTarget } from '@zephyr3d/base';
|
|
|
39
39
|
_options;
|
|
40
40
|
_device;
|
|
41
41
|
_inputManager;
|
|
42
|
-
_running;
|
|
43
42
|
_ready;
|
|
44
|
-
_canRender;
|
|
45
43
|
_drawEvent;
|
|
46
44
|
_logger;
|
|
47
45
|
_elapsed;
|
|
@@ -62,9 +60,7 @@ import { makeEventTarget } from '@zephyr3d/base';
|
|
|
62
60
|
canvas: opt.canvas
|
|
63
61
|
};
|
|
64
62
|
this._inputManager = new InputManager(this);
|
|
65
|
-
this._running = null;
|
|
66
63
|
this._ready = false;
|
|
67
|
-
this._canRender = false;
|
|
68
64
|
this._elapsed = 0;
|
|
69
65
|
this._drawEvent = new AppTickEvent();
|
|
70
66
|
this._logger = {
|
|
@@ -90,14 +86,6 @@ import { makeEventTarget } from '@zephyr3d/base';
|
|
|
90
86
|
return this._options;
|
|
91
87
|
}
|
|
92
88
|
/**
|
|
93
|
-
* Query if the device is ok to render objects now.
|
|
94
|
-
*
|
|
95
|
-
* @remarks
|
|
96
|
-
* False will be returned if the device is lost.
|
|
97
|
-
*/ get canRender() {
|
|
98
|
-
return this._canRender;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
89
|
* Query time elapsed since last frame in seconds
|
|
102
90
|
*/ get timeElapsedInSeconds() {
|
|
103
91
|
return this._elapsed;
|
|
@@ -139,30 +127,20 @@ import { makeEventTarget } from '@zephyr3d/base';
|
|
|
139
127
|
}
|
|
140
128
|
/** Render one frame */ frame() {
|
|
141
129
|
if (this._ready) {
|
|
142
|
-
this._canRender = this.device.beginFrame();
|
|
143
130
|
this._elapsed = this.device.frameInfo.elapsedFrame * 0.001;
|
|
144
131
|
this.device.setFramebuffer(null);
|
|
145
132
|
this.device.setViewport(null);
|
|
146
133
|
this.device.setScissor(null);
|
|
147
134
|
this.dispatchEvent(this._drawEvent);
|
|
148
|
-
this.device.endFrame();
|
|
149
135
|
}
|
|
150
136
|
}
|
|
151
137
|
/** Start running the rendering loop */ run() {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
const that = this;
|
|
156
|
-
(function entry() {
|
|
157
|
-
that._running = requestAnimationFrame(entry);
|
|
158
|
-
that.frame();
|
|
159
|
-
})();
|
|
138
|
+
this.device.runLoop(()=>{
|
|
139
|
+
this.frame();
|
|
140
|
+
});
|
|
160
141
|
}
|
|
161
142
|
/** Stop running the rendering loop */ stop() {
|
|
162
|
-
|
|
163
|
-
cancelAnimationFrame(this._running);
|
|
164
|
-
this._running = null;
|
|
165
|
-
}
|
|
143
|
+
this.device.exitLoop();
|
|
166
144
|
}
|
|
167
145
|
/** Message log */ log(text, mode) {
|
|
168
146
|
this._logger?.log(text, mode);
|
package/dist/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"app.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|