@xviewer.js/core 1.0.0-alpha.58 → 1.0.0-alpha.59
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/main.js +78 -7
- package/dist/main.js.map +1 -1
- package/dist/module.js +79 -9
- package/dist/module.js.map +1 -1
- package/package.json +1 -1
- package/types/components/Animation.d.ts +26 -0
- package/types/components/index.d.ts +1 -0
- package/types/plugins/DropFilePlugin.d.ts +3 -1
package/dist/module.js
CHANGED
|
@@ -3,7 +3,7 @@ import { FBXLoader } from 'three/examples/jsm/loaders/FBXLoader.js';
|
|
|
3
3
|
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
|
4
4
|
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';
|
|
5
5
|
import { MeshoptDecoder } from 'three/examples/jsm/libs/meshopt_decoder.module.js';
|
|
6
|
-
import { EquirectangularReflectionMapping, FileLoader, TextureLoader, SRGBColorSpace, MathUtils, Vector3, Quaternion, Raycaster, Vector2, LinearInterpolant, Spherical, Mesh, BoxGeometry, SphereGeometry, PlaneGeometry, Plane as Plane$1, Matrix4, Vector4, PerspectiveCamera, WebGLRenderTarget, HalfFloatType, LinearMipMapLinearFilter, LinearFilter, ShaderMaterial, UniformsUtils, Color, Scene, OrthographicCamera, NoBlending, AdditiveBlending, FloatType, UnsignedByteType, BufferGeometry, Float32BufferAttribute, Object3D, ClampToEdgeWrapping, NearestFilter, LinearSRGBColorSpace, WebGLCubeRenderTarget, DataTexture, RGBAFormat, UVMapping, WebGLRenderer, PCFSoftShadowMap, LoadingManager, LinearToneMapping, PMREMGenerator, MeshBasicMaterial, CubeCamera, Box3Helper, Box3, ShaderLib, ShaderChunk } from 'three';
|
|
6
|
+
import { EquirectangularReflectionMapping, FileLoader, TextureLoader, SRGBColorSpace, MathUtils, Vector3, Quaternion, Raycaster, Vector2, LinearInterpolant, Spherical, Mesh, BoxGeometry, SphereGeometry, PlaneGeometry, Plane as Plane$1, Matrix4, Vector4, PerspectiveCamera, WebGLRenderTarget, HalfFloatType, LinearMipMapLinearFilter, LinearFilter, AnimationMixer, ShaderMaterial, UniformsUtils, Color, Scene, OrthographicCamera, NoBlending, AdditiveBlending, FloatType, UnsignedByteType, BufferGeometry, Float32BufferAttribute, Object3D, ClampToEdgeWrapping, NearestFilter, LinearSRGBColorSpace, WebGLCubeRenderTarget, DataTexture, RGBAFormat, UVMapping, WebGLRenderer, PCFSoftShadowMap, LoadingManager, LinearToneMapping, PMREMGenerator, MeshBasicMaterial, CubeCamera, Box3Helper, Box3, ShaderLib, ShaderChunk } from 'three';
|
|
7
7
|
import { RGBELoader } from 'three/examples/jsm/loaders/RGBELoader.js';
|
|
8
8
|
|
|
9
9
|
class EventEmitter {
|
|
@@ -1135,7 +1135,7 @@ class aFBXLoader extends aLoader {
|
|
|
1135
1135
|
onLoad(aLoader._setUserData(node));
|
|
1136
1136
|
};
|
|
1137
1137
|
if (buffer) {
|
|
1138
|
-
loadCallback(loader.parse(buffer,
|
|
1138
|
+
loadCallback(loader.parse(buffer, resourcePath));
|
|
1139
1139
|
} else {
|
|
1140
1140
|
loader.load(url, loadCallback, onProgress, onError);
|
|
1141
1141
|
}
|
|
@@ -3177,6 +3177,73 @@ class Reflector extends Component {
|
|
|
3177
3177
|
}
|
|
3178
3178
|
}
|
|
3179
3179
|
|
|
3180
|
+
class Animation extends Component {
|
|
3181
|
+
get mixer() {
|
|
3182
|
+
return this._mixer;
|
|
3183
|
+
}
|
|
3184
|
+
get action() {
|
|
3185
|
+
return this._action;
|
|
3186
|
+
}
|
|
3187
|
+
get actions() {
|
|
3188
|
+
return this._actions;
|
|
3189
|
+
}
|
|
3190
|
+
get progress() {
|
|
3191
|
+
return this._progress;
|
|
3192
|
+
}
|
|
3193
|
+
set progress(v) {
|
|
3194
|
+
if (this.playing) return;
|
|
3195
|
+
if (this._action) {
|
|
3196
|
+
const duration = this._action.getClip().duration;
|
|
3197
|
+
this._mixer.setTime(v * duration);
|
|
3198
|
+
}
|
|
3199
|
+
}
|
|
3200
|
+
onLoad() {
|
|
3201
|
+
this._mixer = new AnimationMixer(this.node);
|
|
3202
|
+
this._actions = this.node.animations.map((v)=>this._mixer.clipAction(v));
|
|
3203
|
+
}
|
|
3204
|
+
onDestroy() {
|
|
3205
|
+
this._mixer.stopAllAction();
|
|
3206
|
+
}
|
|
3207
|
+
update(dt) {
|
|
3208
|
+
if (this.playing) {
|
|
3209
|
+
this._mixer.update(dt);
|
|
3210
|
+
}
|
|
3211
|
+
if (this._action) {
|
|
3212
|
+
const duration = this._action.getClip().duration;
|
|
3213
|
+
this._progress = this._mixer.time % duration / duration;
|
|
3214
|
+
}
|
|
3215
|
+
}
|
|
3216
|
+
play(animName, state = {}) {
|
|
3217
|
+
let action = animName ? this._actions.find((v)=>v.getClip().name === animName) : this._actions[0];
|
|
3218
|
+
if (action) {
|
|
3219
|
+
if (state.clampWhenFinished !== undefined) action.clampWhenFinished = state.clampWhenFinished;
|
|
3220
|
+
if (state.zeroSlopeAtStart !== undefined) action.zeroSlopeAtStart = state.zeroSlopeAtStart;
|
|
3221
|
+
if (state.zeroSlopeAtEnd !== undefined) action.zeroSlopeAtEnd = state.zeroSlopeAtEnd;
|
|
3222
|
+
if (state.mode) action.setLoop(state.mode, state.repetitions);
|
|
3223
|
+
if (state.duration) action.setDuration(state.duration);
|
|
3224
|
+
if (this._action) {
|
|
3225
|
+
this._action.stop();
|
|
3226
|
+
}
|
|
3227
|
+
this._action = action.play();
|
|
3228
|
+
this.playing = true;
|
|
3229
|
+
}
|
|
3230
|
+
return this;
|
|
3231
|
+
}
|
|
3232
|
+
stop() {
|
|
3233
|
+
if (this._action) {
|
|
3234
|
+
this._action.stop();
|
|
3235
|
+
this._action = null;
|
|
3236
|
+
}
|
|
3237
|
+
this.playing = false;
|
|
3238
|
+
return this;
|
|
3239
|
+
}
|
|
3240
|
+
constructor(...args){
|
|
3241
|
+
super(...args);
|
|
3242
|
+
this._progress = 0;
|
|
3243
|
+
this.playing = false;
|
|
3244
|
+
}
|
|
3245
|
+
}
|
|
3246
|
+
|
|
3180
3247
|
const vert_fullscreen = /*glsl*/ `
|
|
3181
3248
|
varying vec2 vUv;
|
|
3182
3249
|
void main() {
|
|
@@ -4334,7 +4401,7 @@ class ResourceManager {
|
|
|
4334
4401
|
}
|
|
4335
4402
|
});
|
|
4336
4403
|
} else {
|
|
4337
|
-
reject("ResourceManager.loadAsset: missing loader for " +
|
|
4404
|
+
reject("ResourceManager.loadAsset: missing loader for " + sel);
|
|
4338
4405
|
}
|
|
4339
4406
|
});
|
|
4340
4407
|
}
|
|
@@ -4671,10 +4738,9 @@ class Viewer extends EventEmitter {
|
|
|
4671
4738
|
const frameCallback = (time)=>{
|
|
4672
4739
|
if (this._running) {
|
|
4673
4740
|
this._frame(time * 0.001);
|
|
4674
|
-
requestAnimationFrame(frameCallback);
|
|
4675
4741
|
}
|
|
4676
4742
|
};
|
|
4677
|
-
|
|
4743
|
+
this._renderer.setAnimationLoop(frameCallback);
|
|
4678
4744
|
}
|
|
4679
4745
|
return this;
|
|
4680
4746
|
}
|
|
@@ -5617,6 +5683,9 @@ class DropFilePlugin extends Plugin {
|
|
|
5617
5683
|
asset.userData.ext = ext;
|
|
5618
5684
|
this._onLoad && this._onLoad(asset);
|
|
5619
5685
|
};
|
|
5686
|
+
const errCallback = (err)=>{
|
|
5687
|
+
this._onError && this._onError(err);
|
|
5688
|
+
};
|
|
5620
5689
|
if ([
|
|
5621
5690
|
"fbx",
|
|
5622
5691
|
"gltf",
|
|
@@ -5627,7 +5696,7 @@ class DropFilePlugin extends Plugin {
|
|
|
5627
5696
|
ext,
|
|
5628
5697
|
buffer: event.target.result,
|
|
5629
5698
|
resourcePath: dir
|
|
5630
|
-
}).then(loadCallback);
|
|
5699
|
+
}).then(loadCallback).catch(errCallback);
|
|
5631
5700
|
}, false);
|
|
5632
5701
|
reader.readAsArrayBuffer(file);
|
|
5633
5702
|
} else {
|
|
@@ -5635,13 +5704,13 @@ class DropFilePlugin extends Plugin {
|
|
|
5635
5704
|
this.viewer.loadAsset({
|
|
5636
5705
|
ext,
|
|
5637
5706
|
url: event.target.result
|
|
5638
|
-
}).then(loadCallback);
|
|
5707
|
+
}).then(loadCallback).catch(errCallback);
|
|
5639
5708
|
}, false);
|
|
5640
5709
|
reader.readAsDataURL(file);
|
|
5641
5710
|
}
|
|
5642
5711
|
}
|
|
5643
5712
|
}
|
|
5644
|
-
constructor({ onLoad, extension = [
|
|
5713
|
+
constructor({ onLoad, onError, extension = [
|
|
5645
5714
|
"glb",
|
|
5646
5715
|
"gltf",
|
|
5647
5716
|
"fbx",
|
|
@@ -5662,6 +5731,7 @@ class DropFilePlugin extends Plugin {
|
|
|
5662
5731
|
}
|
|
5663
5732
|
};
|
|
5664
5733
|
this._onLoad = onLoad;
|
|
5734
|
+
this._onError = onError;
|
|
5665
5735
|
this._extensions = Array.isArray(extension) ? extension : [
|
|
5666
5736
|
extension
|
|
5667
5737
|
];
|
|
@@ -5714,5 +5784,5 @@ function getFilesFromItemList(items, onDone) {
|
|
|
5714
5784
|
}
|
|
5715
5785
|
}
|
|
5716
5786
|
|
|
5717
|
-
export { AnimationCurve, Box, BoxProjectionPlugin, CinestationBlendDefinition, CinestationBrain, Component, DebugPlugin, DeviceInput, DropFilePlugin, Easing, EnvironmentPlugin, EventEmitter, FInterpConstantTo, FInterpTo, FreelookVirtualCamera, Logger, ObjectInstance, Orientation, PerformanceMonitorPlugin, Perlin, Plane, Plugin, PropertyManager, QInterpConstantTo, QInterpTo, Quat_AngularDistance, Quat_Equals, Quat_exponentialDamp, Quat_quarticDamp, Quat_smoothDamp, Reflector, ReflectorMaterial, ResourceManager, Sphere, SystemInfo, Tween, TweenChain, TweenManager, VInterpConstantTo, VInterpTo, Vec3_smoothDamp, Vector3_NEG_ONE, Vector3_ONE, Vector3_RIGHT, Vector3_UNIT_X, Vector3_UNIT_Y, Vector3_UNIT_Z, Vector3_UP, Vector3_ZERO, Viewer, VirtualCamera, aEXRLoader, aFBXLoader, aGLTFLoader, aHDRLoader, aJSONLoader, aLoader, aTextureLoader, exponentialDamp, frag_BoxfilterBlur, frag_cubeMapToPanorama, frag_panoramaToCubeMap, getClassInstance, getShaderMaterial, mixin, property, quarticDamp, smoothDamp, vert_fullscreen };
|
|
5787
|
+
export { Animation, AnimationCurve, Box, BoxProjectionPlugin, CinestationBlendDefinition, CinestationBrain, Component, DebugPlugin, DeviceInput, DropFilePlugin, Easing, EnvironmentPlugin, EventEmitter, FInterpConstantTo, FInterpTo, FreelookVirtualCamera, Logger, ObjectInstance, Orientation, PerformanceMonitorPlugin, Perlin, Plane, Plugin, PropertyManager, QInterpConstantTo, QInterpTo, Quat_AngularDistance, Quat_Equals, Quat_exponentialDamp, Quat_quarticDamp, Quat_smoothDamp, Reflector, ReflectorMaterial, ResourceManager, Sphere, SystemInfo, Tween, TweenChain, TweenManager, VInterpConstantTo, VInterpTo, Vec3_smoothDamp, Vector3_NEG_ONE, Vector3_ONE, Vector3_RIGHT, Vector3_UNIT_X, Vector3_UNIT_Y, Vector3_UNIT_Z, Vector3_UP, Vector3_ZERO, Viewer, VirtualCamera, aEXRLoader, aFBXLoader, aGLTFLoader, aHDRLoader, aJSONLoader, aLoader, aTextureLoader, exponentialDamp, frag_BoxfilterBlur, frag_cubeMapToPanorama, frag_panoramaToCubeMap, getClassInstance, getShaderMaterial, mixin, property, quarticDamp, smoothDamp, vert_fullscreen };
|
|
5718
5788
|
//# sourceMappingURL=module.js.map
|