@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/main.js
CHANGED
|
@@ -1137,7 +1137,7 @@ class aFBXLoader extends aLoader {
|
|
|
1137
1137
|
onLoad(aLoader._setUserData(node));
|
|
1138
1138
|
};
|
|
1139
1139
|
if (buffer) {
|
|
1140
|
-
loadCallback(loader.parse(buffer,
|
|
1140
|
+
loadCallback(loader.parse(buffer, resourcePath));
|
|
1141
1141
|
} else {
|
|
1142
1142
|
loader.load(url, loadCallback, onProgress, onError);
|
|
1143
1143
|
}
|
|
@@ -3179,6 +3179,73 @@ class Reflector extends Component {
|
|
|
3179
3179
|
}
|
|
3180
3180
|
}
|
|
3181
3181
|
|
|
3182
|
+
class Animation extends Component {
|
|
3183
|
+
get mixer() {
|
|
3184
|
+
return this._mixer;
|
|
3185
|
+
}
|
|
3186
|
+
get action() {
|
|
3187
|
+
return this._action;
|
|
3188
|
+
}
|
|
3189
|
+
get actions() {
|
|
3190
|
+
return this._actions;
|
|
3191
|
+
}
|
|
3192
|
+
get progress() {
|
|
3193
|
+
return this._progress;
|
|
3194
|
+
}
|
|
3195
|
+
set progress(v) {
|
|
3196
|
+
if (this.playing) return;
|
|
3197
|
+
if (this._action) {
|
|
3198
|
+
const duration = this._action.getClip().duration;
|
|
3199
|
+
this._mixer.setTime(v * duration);
|
|
3200
|
+
}
|
|
3201
|
+
}
|
|
3202
|
+
onLoad() {
|
|
3203
|
+
this._mixer = new three.AnimationMixer(this.node);
|
|
3204
|
+
this._actions = this.node.animations.map((v)=>this._mixer.clipAction(v));
|
|
3205
|
+
}
|
|
3206
|
+
onDestroy() {
|
|
3207
|
+
this._mixer.stopAllAction();
|
|
3208
|
+
}
|
|
3209
|
+
update(dt) {
|
|
3210
|
+
if (this.playing) {
|
|
3211
|
+
this._mixer.update(dt);
|
|
3212
|
+
}
|
|
3213
|
+
if (this._action) {
|
|
3214
|
+
const duration = this._action.getClip().duration;
|
|
3215
|
+
this._progress = this._mixer.time % duration / duration;
|
|
3216
|
+
}
|
|
3217
|
+
}
|
|
3218
|
+
play(animName, state = {}) {
|
|
3219
|
+
let action = animName ? this._actions.find((v)=>v.getClip().name === animName) : this._actions[0];
|
|
3220
|
+
if (action) {
|
|
3221
|
+
if (state.clampWhenFinished !== undefined) action.clampWhenFinished = state.clampWhenFinished;
|
|
3222
|
+
if (state.zeroSlopeAtStart !== undefined) action.zeroSlopeAtStart = state.zeroSlopeAtStart;
|
|
3223
|
+
if (state.zeroSlopeAtEnd !== undefined) action.zeroSlopeAtEnd = state.zeroSlopeAtEnd;
|
|
3224
|
+
if (state.mode) action.setLoop(state.mode, state.repetitions);
|
|
3225
|
+
if (state.duration) action.setDuration(state.duration);
|
|
3226
|
+
if (this._action) {
|
|
3227
|
+
this._action.stop();
|
|
3228
|
+
}
|
|
3229
|
+
this._action = action.play();
|
|
3230
|
+
this.playing = true;
|
|
3231
|
+
}
|
|
3232
|
+
return this;
|
|
3233
|
+
}
|
|
3234
|
+
stop() {
|
|
3235
|
+
if (this._action) {
|
|
3236
|
+
this._action.stop();
|
|
3237
|
+
this._action = null;
|
|
3238
|
+
}
|
|
3239
|
+
this.playing = false;
|
|
3240
|
+
return this;
|
|
3241
|
+
}
|
|
3242
|
+
constructor(...args){
|
|
3243
|
+
super(...args);
|
|
3244
|
+
this._progress = 0;
|
|
3245
|
+
this.playing = false;
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3248
|
+
|
|
3182
3249
|
const vert_fullscreen = /*glsl*/ `
|
|
3183
3250
|
varying vec2 vUv;
|
|
3184
3251
|
void main() {
|
|
@@ -4336,7 +4403,7 @@ class ResourceManager {
|
|
|
4336
4403
|
}
|
|
4337
4404
|
});
|
|
4338
4405
|
} else {
|
|
4339
|
-
reject("ResourceManager.loadAsset: missing loader for " +
|
|
4406
|
+
reject("ResourceManager.loadAsset: missing loader for " + sel);
|
|
4340
4407
|
}
|
|
4341
4408
|
});
|
|
4342
4409
|
}
|
|
@@ -4673,10 +4740,9 @@ class Viewer extends EventEmitter {
|
|
|
4673
4740
|
const frameCallback = (time)=>{
|
|
4674
4741
|
if (this._running) {
|
|
4675
4742
|
this._frame(time * 0.001);
|
|
4676
|
-
requestAnimationFrame(frameCallback);
|
|
4677
4743
|
}
|
|
4678
4744
|
};
|
|
4679
|
-
|
|
4745
|
+
this._renderer.setAnimationLoop(frameCallback);
|
|
4680
4746
|
}
|
|
4681
4747
|
return this;
|
|
4682
4748
|
}
|
|
@@ -4985,6 +5051,7 @@ class Viewer extends EventEmitter {
|
|
|
4985
5051
|
this._input.addEventListeners();
|
|
4986
5052
|
this._addDefaultLoaders();
|
|
4987
5053
|
if (autoStart) this.start();
|
|
5054
|
+
this.resize();
|
|
4988
5055
|
}
|
|
4989
5056
|
}
|
|
4990
5057
|
Viewer.__target = new three.Vector3();
|
|
@@ -5618,6 +5685,9 @@ class DropFilePlugin extends Plugin {
|
|
|
5618
5685
|
asset.userData.ext = ext;
|
|
5619
5686
|
this._onLoad && this._onLoad(asset);
|
|
5620
5687
|
};
|
|
5688
|
+
const errCallback = (err)=>{
|
|
5689
|
+
this._onError && this._onError(err);
|
|
5690
|
+
};
|
|
5621
5691
|
if ([
|
|
5622
5692
|
"fbx",
|
|
5623
5693
|
"gltf",
|
|
@@ -5628,7 +5698,7 @@ class DropFilePlugin extends Plugin {
|
|
|
5628
5698
|
ext,
|
|
5629
5699
|
buffer: event.target.result,
|
|
5630
5700
|
resourcePath: dir
|
|
5631
|
-
}).then(loadCallback);
|
|
5701
|
+
}).then(loadCallback).catch(errCallback);
|
|
5632
5702
|
}, false);
|
|
5633
5703
|
reader.readAsArrayBuffer(file);
|
|
5634
5704
|
} else {
|
|
@@ -5636,13 +5706,13 @@ class DropFilePlugin extends Plugin {
|
|
|
5636
5706
|
this.viewer.loadAsset({
|
|
5637
5707
|
ext,
|
|
5638
5708
|
url: event.target.result
|
|
5639
|
-
}).then(loadCallback);
|
|
5709
|
+
}).then(loadCallback).catch(errCallback);
|
|
5640
5710
|
}, false);
|
|
5641
5711
|
reader.readAsDataURL(file);
|
|
5642
5712
|
}
|
|
5643
5713
|
}
|
|
5644
5714
|
}
|
|
5645
|
-
constructor({ onLoad, extension = [
|
|
5715
|
+
constructor({ onLoad, onError, extension = [
|
|
5646
5716
|
"glb",
|
|
5647
5717
|
"gltf",
|
|
5648
5718
|
"fbx",
|
|
@@ -5663,6 +5733,7 @@ class DropFilePlugin extends Plugin {
|
|
|
5663
5733
|
}
|
|
5664
5734
|
};
|
|
5665
5735
|
this._onLoad = onLoad;
|
|
5736
|
+
this._onError = onError;
|
|
5666
5737
|
this._extensions = Array.isArray(extension) ? extension : [
|
|
5667
5738
|
extension
|
|
5668
5739
|
];
|
|
@@ -5715,6 +5786,7 @@ function getFilesFromItemList(items, onDone) {
|
|
|
5715
5786
|
}
|
|
5716
5787
|
}
|
|
5717
5788
|
|
|
5789
|
+
exports.Animation = Animation;
|
|
5718
5790
|
exports.AnimationCurve = AnimationCurve;
|
|
5719
5791
|
exports.Box = Box;
|
|
5720
5792
|
exports.BoxProjectionPlugin = BoxProjectionPlugin;
|