@xviewer.js/core 1.0.0-alpha.4 → 1.0.0-alpha.6

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/module.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Mesh, TrianglesDrawMode, TriangleFanDrawMode, TriangleStripDrawMode, Loader, LoaderUtils, FileLoader, Color, LinearSRGBColorSpace, SpotLight, PointLight, DirectionalLight, MeshBasicMaterial, SRGBColorSpace, MeshPhysicalMaterial, Vector2, Matrix4, Vector3, Quaternion, InstancedMesh, InstancedBufferAttribute, Object3D, TextureLoader, ImageBitmapLoader, BufferAttribute, InterleavedBuffer, InterleavedBufferAttribute, LinearFilter, LinearMipmapLinearFilter, RepeatWrapping, PointsMaterial, Material, LineBasicMaterial, MeshStandardMaterial, DoubleSide, PropertyBinding, BufferGeometry, SkinnedMesh, LineSegments, Line, LineLoop, Points, Group as Group$1, PerspectiveCamera, MathUtils, OrthographicCamera, Skeleton, AnimationClip, Bone, InterpolateLinear, ColorManagement, NearestFilter, NearestMipmapNearestFilter, LinearMipmapNearestFilter, NearestMipmapLinearFilter, ClampToEdgeWrapping, MirroredRepeatWrapping, InterpolateDiscrete, FrontSide, Texture, VectorKeyframeTrack, NumberKeyframeTrack, QuaternionKeyframeTrack, Box3, Sphere as Sphere$1, Interpolant, Vector4, Curve, MeshPhongMaterial, MeshLambertMaterial, EquirectangularReflectionMapping, AmbientLight, Float32BufferAttribute, Uint16BufferAttribute, Matrix3, ShapeUtils, Euler, DataTextureLoader, HalfFloatType, FloatType, DataUtils, Raycaster, Spherical, BoxGeometry, SphereGeometry, PlaneGeometry, UnsignedByteType, WebGLRenderTarget, LinearMipMapLinearFilter, WebGLCubeRenderTarget, DataTexture, RGBAFormat, UVMapping, Scene, LinearToneMapping, WebGLRenderer, PCFSoftShadowMap, LoadingManager } from 'three';
1
+ import { Mesh, TrianglesDrawMode, TriangleFanDrawMode, TriangleStripDrawMode, Loader, LoaderUtils, FileLoader, Color, LinearSRGBColorSpace, SpotLight, PointLight, DirectionalLight, MeshBasicMaterial, SRGBColorSpace, MeshPhysicalMaterial, Vector2, Matrix4, Vector3, Quaternion, InstancedMesh, InstancedBufferAttribute, Object3D, TextureLoader, ImageBitmapLoader, BufferAttribute, InterleavedBuffer, InterleavedBufferAttribute, LinearFilter, LinearMipmapLinearFilter, RepeatWrapping, PointsMaterial, Material, LineBasicMaterial, MeshStandardMaterial, DoubleSide, PropertyBinding, BufferGeometry, SkinnedMesh, LineSegments, Line, LineLoop, Points, Group as Group$1, PerspectiveCamera, MathUtils, OrthographicCamera, Skeleton, AnimationClip, Bone, InterpolateLinear, ColorManagement, NearestFilter, NearestMipmapNearestFilter, LinearMipmapNearestFilter, NearestMipmapLinearFilter, ClampToEdgeWrapping, MirroredRepeatWrapping, InterpolateDiscrete, FrontSide, Texture, VectorKeyframeTrack, NumberKeyframeTrack, QuaternionKeyframeTrack, Box3, Sphere as Sphere$1, Interpolant, Vector4, Curve, MeshPhongMaterial, MeshLambertMaterial, EquirectangularReflectionMapping, AmbientLight, Float32BufferAttribute, Uint16BufferAttribute, Matrix3, ShapeUtils, Euler, DataTextureLoader, HalfFloatType, FloatType, DataUtils, Raycaster, Spherical, BoxGeometry, SphereGeometry, PlaneGeometry, UnsignedByteType, WebGLRenderTarget, LinearMipMapLinearFilter, WebGLCubeRenderTarget, DataTexture, RGBAFormat, UVMapping, Scene, WebGLRenderer, PCFSoftShadowMap, LoadingManager, LinearToneMapping } from 'three';
2
2
 
3
3
  class EventEmitter {
4
4
  _removeEvent(list, index, name) {
@@ -1063,22 +1063,6 @@ class aLoader {
1063
1063
  }
1064
1064
  }
1065
1065
 
1066
- function _object_without_properties_loose(source, excluded) {
1067
- if (source == null) return {};
1068
-
1069
- var target = {};
1070
- var sourceKeys = Object.keys(source);
1071
- var key, i;
1072
-
1073
- for (i = 0; i < sourceKeys.length; i++) {
1074
- key = sourceKeys[i];
1075
- if (excluded.indexOf(key) >= 0) continue;
1076
- target[key] = source[key];
1077
- }
1078
-
1079
- return target;
1080
- }
1081
-
1082
1066
  class ResourceManager {
1083
1067
  static extension(path) {
1084
1068
  let str = path.split(".");
@@ -1148,12 +1132,7 @@ class ResourceManager {
1148
1132
  destroy() {
1149
1133
  this._caches.clear();
1150
1134
  }
1151
- loadAsset(_param) {
1152
- var { url, ext, onProgress } = _param, props = _object_without_properties_loose(_param, [
1153
- "url",
1154
- "ext",
1155
- "onProgress"
1156
- ]);
1135
+ loadAsset({ url, ext, onProgress, ...props }) {
1157
1136
  return new Promise((resolve, reject)=>{
1158
1137
  const info = ResourceManager._parseURL(url);
1159
1138
  const texSettings = ResourceManager._splitTextureSettings(props);
@@ -6762,7 +6741,7 @@ class aGLTFLoader extends aLoader {
6762
6741
  if (gltf.animations) node.animations = gltf.animations;
6763
6742
  onLoad(aLoader._setMeshData(node));
6764
6743
  };
6765
- let gltfLoader = new GLTFLoader(this.loadingManager);
6744
+ let gltfLoader = new GLTFLoader(this.manager.loadingManager);
6766
6745
  gltfLoader.setPath(this.manager.path);
6767
6746
  gltfLoader.setResourcePath(this.manager.resourcePath);
6768
6747
  let dracoLoader = new DRACOLoader(this.manager.loadingManager);
@@ -13201,11 +13180,10 @@ const Vector3_ZERO = new Vector3();
13201
13180
 
13202
13181
  const { clamp, degToRad } = MathUtils;
13203
13182
  const { abs, tan } = Math;
13204
- var VCamFreeLookMode;
13205
- (function(VCamFreeLookMode) {
13206
- VCamFreeLookMode[VCamFreeLookMode["FREE"] = 0] = "FREE";
13207
- VCamFreeLookMode[VCamFreeLookMode["TRANSLATE"] = 1] = "TRANSLATE";
13208
- })(VCamFreeLookMode || (VCamFreeLookMode = {}));
13183
+ const VCamFreeLookMode = {
13184
+ FREE: 0,
13185
+ TRANSLATE: 1
13186
+ };
13209
13187
  class FreelookVirtualCamera extends VirtualCamera {
13210
13188
  onEnable() {
13211
13189
  this.viewer.on(DeviceInput.POINTER_DOWN, this._onPointerDown, this);
@@ -13344,7 +13322,7 @@ class FreelookVirtualCamera extends VirtualCamera {
13344
13322
  const { __posDelta, __posOffset, __worldPos, __quat, __spherical, __xAxis, __yAxis } = FreelookVirtualCamera;
13345
13323
  __worldPos.copy(this.lookAt.position).add(this.trackedObjectOffset);
13346
13324
  switch(this.mode){
13347
- case 0:
13325
+ case VCamFreeLookMode.FREE:
13348
13326
  if (abs(this._rotateDelta.x) + abs(this._rotateDelta.y) + abs(this._distanceDelta) > 0.001) {
13349
13327
  const { __posDelta, __posOffset, __worldPos } = FreelookVirtualCamera;
13350
13328
  __quat.setFromUnitVectors(this.node.up, Object3D.DEFAULT_UP);
@@ -13365,7 +13343,7 @@ class FreelookVirtualCamera extends VirtualCamera {
13365
13343
  this.node.position.copy(__posDelta.add(__worldPos));
13366
13344
  }
13367
13345
  break;
13368
- case 1:
13346
+ case VCamFreeLookMode.TRANSLATE:
13369
13347
  if (abs(this._distanceDelta) > 0.001) {
13370
13348
  __posDelta.copy(this.node.position).sub(this.lookAt.position);
13371
13349
  let dampFactor = quarticDamp(1, 0, this.rotateSmoothing, dt);
@@ -13409,7 +13387,7 @@ class FreelookVirtualCamera extends VirtualCamera {
13409
13387
  this._preLoc1 = new Vector2();
13410
13388
  this._rotateDelta = new Vector2();
13411
13389
  this._panDelta = new Vector2();
13412
- this.mode = 0;
13390
+ this.mode = VCamFreeLookMode.FREE;
13413
13391
  this.forbidX = false;
13414
13392
  this.forbidY = false;
13415
13393
  this.forbidZ = false;
@@ -13465,10 +13443,7 @@ FreelookVirtualCamera.__quat = new Quaternion();
13465
13443
  FreelookVirtualCamera.__spherical = new Spherical();
13466
13444
  __decorate([
13467
13445
  property({
13468
- value: {
13469
- FREE: 0,
13470
- TRANSLATE: 1
13471
- }
13446
+ value: VCamFreeLookMode
13472
13447
  })
13473
13448
  ], FreelookVirtualCamera.prototype, "mode", void 0);
13474
13449
  __decorate([
@@ -13520,37 +13495,6 @@ class Plane extends Mesh {
13520
13495
  }
13521
13496
  }
13522
13497
 
13523
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
13524
- try {
13525
- var info = gen[key](arg);
13526
- var value = info.value;
13527
- } catch (error) {
13528
- reject(error);
13529
- return;
13530
- }
13531
- if (info.done) resolve(value);
13532
- else Promise.resolve(value).then(_next, _throw);
13533
- }
13534
- function _async_to_generator(fn) {
13535
- return function() {
13536
- var self = this, args = arguments;
13537
-
13538
- return new Promise(function(resolve, reject) {
13539
- var gen = fn.apply(self, args);
13540
-
13541
- function _next(value) {
13542
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
13543
- }
13544
-
13545
- function _throw(err) {
13546
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
13547
- }
13548
-
13549
- _next(undefined);
13550
- });
13551
- };
13552
- }
13553
-
13554
13498
  class Caller {
13555
13499
  get pause() {
13556
13500
  return this._pause;
@@ -14282,30 +14226,20 @@ class Viewer extends EventEmitter {
14282
14226
  loadAsset(props) {
14283
14227
  return this._resourceManager.loadAsset(props);
14284
14228
  }
14285
- load(_param) {
14286
- var _this = this;
14287
- return _async_to_generator(function*() {
14288
- var { url, ext, onProgress, castShadow = false, receiveShadow = false } = _param, props = _object_without_properties_loose(_param, [
14289
- "url",
14290
- "ext",
14291
- "onProgress",
14292
- "castShadow",
14293
- "receiveShadow"
14294
- ]);
14295
- const node = yield _this.loadAsset({
14296
- url,
14297
- ext,
14298
- onProgress
14229
+ async load({ url, ext, onProgress, castShadow = false, receiveShadow = false, ...props }) {
14230
+ const node = await this.loadAsset({
14231
+ url,
14232
+ ext,
14233
+ onProgress
14234
+ });
14235
+ if (castShadow || receiveShadow) {
14236
+ node.userData.meshData.meshes.forEach((v)=>{
14237
+ v.castShadow = castShadow;
14238
+ v.receiveShadow = receiveShadow;
14299
14239
  });
14300
- if (castShadow || receiveShadow) {
14301
- node.userData.meshData.meshes.forEach((v)=>{
14302
- v.castShadow = castShadow;
14303
- v.receiveShadow = receiveShadow;
14304
- });
14305
- }
14306
- _this.addNode(node, props);
14307
- return node;
14308
- })();
14240
+ }
14241
+ this.addNode(node, props);
14242
+ return node;
14309
14243
  }
14310
14244
  tween(target) {
14311
14245
  return this._tweenManager.tween(target);
@@ -14354,18 +14288,7 @@ class Viewer extends EventEmitter {
14354
14288
  removeComponent(node, component) {
14355
14289
  return this._componentManager.removeComponent(node, component);
14356
14290
  }
14357
- addNode(object, _param = {}) {
14358
- var { args, debug, scale, position, rotation, shadowArgs, makeDefault, component, parent = this._scene } = _param, props = _object_without_properties_loose(_param, [
14359
- "args",
14360
- "debug",
14361
- "scale",
14362
- "position",
14363
- "rotation",
14364
- "shadowArgs",
14365
- "makeDefault",
14366
- "component",
14367
- "parent"
14368
- ]);
14291
+ addNode(object, { args, debug, scale, position, rotation, shadowArgs, makeDefault, component, parent = this._scene, ...props } = {}) {
14369
14292
  let node = null;
14370
14293
  let ins = Viewer._getClassInstance(object, args);
14371
14294
  if (ins.isObject3D) {
@@ -14413,12 +14336,6 @@ class Viewer extends EventEmitter {
14413
14336
  this._componentManager.activeComponents(node);
14414
14337
  node.visible = active;
14415
14338
  }
14416
- createComponent(comp, _param = {}) {
14417
- var { args } = _param, props = _object_without_properties_loose(_param, [
14418
- "args"
14419
- ]);
14420
- return applyProps(Viewer._getClassInstance(comp, args), props);
14421
- }
14422
14339
  createRenderTarget(width, height, nearest = false, floatType = false, msaa = 0, mipmap = false) {
14423
14340
  return new WebGLRenderTarget(width, height, {
14424
14341
  wrapS: ClampToEdgeWrapping,
@@ -14492,30 +14409,12 @@ class Viewer extends EventEmitter {
14492
14409
  Viewer.CompileObject3D(this._renderer, this._scene, this._camera, this._scene);
14493
14410
  }
14494
14411
  }
14495
- constructor(_param = {}){
14496
- var { root, canvas, autoStart = true, autoResize = true, shadows = false, camera = {
14497
- fov: 45,
14498
- near: 1,
14499
- far: 1000,
14500
- position: new Vector3(0, 0, 4)
14501
- }, targetFrameRate = -1, colorSpace = SRGBColorSpace, toneMapping = LinearToneMapping, toneMappingExposure = 1, maxDPR = 1.5, path = "", resourcePath = "", dracoPath = "https://www.gstatic.com/draco/v1/decoders/", loader = {}, tasker = {} } = _param, webglOpts = _object_without_properties_loose(_param, [
14502
- "root",
14503
- "canvas",
14504
- "autoStart",
14505
- "autoResize",
14506
- "shadows",
14507
- "camera",
14508
- "targetFrameRate",
14509
- "colorSpace",
14510
- "toneMapping",
14511
- "toneMappingExposure",
14512
- "maxDPR",
14513
- "path",
14514
- "resourcePath",
14515
- "dracoPath",
14516
- "loader",
14517
- "tasker"
14518
- ]);
14412
+ constructor({ root, canvas, autoStart = true, autoResize = true, shadows = false, camera = {
14413
+ fov: 45,
14414
+ near: 1,
14415
+ far: 1000,
14416
+ position: new Vector3(0, 0, 4)
14417
+ }, targetFrameRate = -1, colorSpace = SRGBColorSpace, toneMapping = LinearToneMapping, toneMappingExposure = 1, maxDPR = 1.5, path = "", resourcePath = "", dracoPath = "https://www.gstatic.com/draco/v1/decoders/", loader = {}, tasker = {}, ...webglOpts } = {}){
14519
14418
  super();
14520
14419
  this._dpr = 1;
14521
14420
  this._width = 1;