@xviewer.js/core 1.0.0-alpha.57 → 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 +79 -7
- package/dist/main.js.map +1 -1
- package/dist/module.js +80 -9
- package/dist/module.js.map +1 -1
- package/package.json +1 -1
- package/types/base/EventEmitter.d.ts +10 -10
- 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
|
}
|
|
@@ -4983,6 +5049,7 @@ class Viewer extends EventEmitter {
|
|
|
4983
5049
|
this._input.addEventListeners();
|
|
4984
5050
|
this._addDefaultLoaders();
|
|
4985
5051
|
if (autoStart) this.start();
|
|
5052
|
+
this.resize();
|
|
4986
5053
|
}
|
|
4987
5054
|
}
|
|
4988
5055
|
Viewer.__target = new Vector3();
|
|
@@ -5616,6 +5683,9 @@ class DropFilePlugin extends Plugin {
|
|
|
5616
5683
|
asset.userData.ext = ext;
|
|
5617
5684
|
this._onLoad && this._onLoad(asset);
|
|
5618
5685
|
};
|
|
5686
|
+
const errCallback = (err)=>{
|
|
5687
|
+
this._onError && this._onError(err);
|
|
5688
|
+
};
|
|
5619
5689
|
if ([
|
|
5620
5690
|
"fbx",
|
|
5621
5691
|
"gltf",
|
|
@@ -5626,7 +5696,7 @@ class DropFilePlugin extends Plugin {
|
|
|
5626
5696
|
ext,
|
|
5627
5697
|
buffer: event.target.result,
|
|
5628
5698
|
resourcePath: dir
|
|
5629
|
-
}).then(loadCallback);
|
|
5699
|
+
}).then(loadCallback).catch(errCallback);
|
|
5630
5700
|
}, false);
|
|
5631
5701
|
reader.readAsArrayBuffer(file);
|
|
5632
5702
|
} else {
|
|
@@ -5634,13 +5704,13 @@ class DropFilePlugin extends Plugin {
|
|
|
5634
5704
|
this.viewer.loadAsset({
|
|
5635
5705
|
ext,
|
|
5636
5706
|
url: event.target.result
|
|
5637
|
-
}).then(loadCallback);
|
|
5707
|
+
}).then(loadCallback).catch(errCallback);
|
|
5638
5708
|
}, false);
|
|
5639
5709
|
reader.readAsDataURL(file);
|
|
5640
5710
|
}
|
|
5641
5711
|
}
|
|
5642
5712
|
}
|
|
5643
|
-
constructor({ onLoad, extension = [
|
|
5713
|
+
constructor({ onLoad, onError, extension = [
|
|
5644
5714
|
"glb",
|
|
5645
5715
|
"gltf",
|
|
5646
5716
|
"fbx",
|
|
@@ -5661,6 +5731,7 @@ class DropFilePlugin extends Plugin {
|
|
|
5661
5731
|
}
|
|
5662
5732
|
};
|
|
5663
5733
|
this._onLoad = onLoad;
|
|
5734
|
+
this._onError = onError;
|
|
5664
5735
|
this._extensions = Array.isArray(extension) ? extension : [
|
|
5665
5736
|
extension
|
|
5666
5737
|
];
|
|
@@ -5713,5 +5784,5 @@ function getFilesFromItemList(items, onDone) {
|
|
|
5713
5784
|
}
|
|
5714
5785
|
}
|
|
5715
5786
|
|
|
5716
|
-
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 };
|
|
5717
5788
|
//# sourceMappingURL=module.js.map
|