@needle-tools/gltf-progressive 3.3.2 → 3.3.3-next.ff6503a

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/lib/lods.debug.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { getParam } from "./utils.internal.js";
2
2
  export const debug = getParam("debugprogressive");
3
- let debug_RenderWireframe;
3
+ let debug_RenderWireframe = undefined;
4
4
  export let debug_OverrideLodLevel = -1; // -1 is automatic
5
5
  if (debug) {
6
6
  let maxLevel = 6;
@@ -28,14 +28,16 @@ if (debug) {
28
28
  export function applyDebugSettings(material) {
29
29
  if (!debug)
30
30
  return;
31
- if (Array.isArray(material)) {
32
- for (const mat of material) {
33
- applyDebugSettings(mat);
31
+ if (debug_RenderWireframe !== undefined) {
32
+ if (Array.isArray(material)) {
33
+ for (const mat of material) {
34
+ applyDebugSettings(mat);
35
+ }
34
36
  }
35
- }
36
- else if (material) {
37
- if ("wireframe" in material) {
38
- material.wireframe = debug_RenderWireframe === true;
37
+ else if (material) {
38
+ if ("wireframe" in material) {
39
+ material.wireframe = debug_RenderWireframe === true;
40
+ }
39
41
  }
40
42
  }
41
43
  }
@@ -1,5 +1,5 @@
1
1
  import { LODsManager } from "../lods.manager.js";
2
- import { EXTENSION_NAME, NEEDLE_progressive } from "../extension.js";
2
+ import { EXTENSION_NAME, NEEDLE_progressive, } from "../extension.js";
3
3
  const $meshLODSymbol = Symbol("NEEDLE_mesh_lod");
4
4
  const $textureLODSymbol = Symbol("NEEDLE_texture_lod");
5
5
  let documentObserver = null;
@@ -1,5 +1,5 @@
1
1
  import { WebGLRenderer, Scene, Camera, Mesh } from 'three';
2
- import { NEEDLE_ext_progressive_mesh } from '../extension.js';
2
+ import { NEEDLE_ext_progressive_mesh } from '../extension.model.js';
3
3
  /**
4
4
  * This interface is used to define a plugin for the progressive extension. It can be registered using the `registerPlugin` function.
5
5
  */
@@ -1,12 +1,22 @@
1
1
  export declare function isDebugMode(): string | boolean;
2
2
  export declare function getParam(name: string): boolean | string;
3
3
  export declare function resolveUrl(source: string | undefined, uri: string): string;
4
- /** @returns `true` if it's a phone or tablet */
4
+ /** Check if the current device is a mobile device.
5
+ * @returns `true` if it's a phone or tablet
6
+ */
5
7
  export declare function isMobileDevice(): boolean;
8
+ /**
9
+ * Check if we are running in a development server (localhost or ip address).
10
+ * @returns `true` if we are running in a development server (localhost or ip address).
11
+ */
6
12
  export declare function isDevelopmentServer(): boolean;
7
13
  export type SlotReturnValue<T = any> = {
8
14
  use?: ((promise: Promise<T>) => void);
9
15
  };
16
+ /**
17
+ * A promise queue that limits the number of concurrent promises.
18
+ * Use the `slot` method to request a slot for a promise with a specific key. The returned promise resolves to an object with a `use` method that can be called to add the promise to the queue.
19
+ */
10
20
  export declare class PromiseQueue<T = any> {
11
21
  readonly maxConcurrent: number;
12
22
  private readonly _running;
@@ -14,18 +14,16 @@ export function getParam(name) {
14
14
  return param;
15
15
  }
16
16
  export function resolveUrl(source, uri) {
17
- if (uri === undefined) {
17
+ if (uri === undefined || source === undefined) {
18
18
  return uri;
19
19
  }
20
- if (uri.startsWith("./")) {
21
- return uri;
22
- }
23
- if (uri.startsWith("http")) {
24
- return uri;
25
- }
26
- if (source === undefined) {
20
+ if (uri.startsWith("./") ||
21
+ uri.startsWith("http") ||
22
+ uri.startsWith("data:") ||
23
+ uri.startsWith("blob:")) {
27
24
  return uri;
28
25
  }
26
+ // TODO: why not just use new URL(uri, source).href ?
29
27
  const pathIndex = source.lastIndexOf("/");
30
28
  if (pathIndex >= 0) {
31
29
  // Take the source uri as the base path
@@ -40,8 +38,9 @@ export function resolveUrl(source, uri) {
40
38
  }
41
39
  return uri;
42
40
  }
43
- let _ismobile;
44
- /** @returns `true` if it's a phone or tablet */
41
+ /** Check if the current device is a mobile device.
42
+ * @returns `true` if it's a phone or tablet
43
+ */
45
44
  export function isMobileDevice() {
46
45
  if (_ismobile !== undefined)
47
46
  return _ismobile;
@@ -50,6 +49,11 @@ export function isMobileDevice() {
50
49
  console.log("[glTF Progressive]: isMobileDevice", _ismobile);
51
50
  return _ismobile;
52
51
  }
52
+ let _ismobile;
53
+ /**
54
+ * Check if we are running in a development server (localhost or ip address).
55
+ * @returns `true` if we are running in a development server (localhost or ip address).
56
+ */
53
57
  export function isDevelopmentServer() {
54
58
  if (typeof window === "undefined")
55
59
  return false;
@@ -58,6 +62,10 @@ export function isDevelopmentServer() {
58
62
  const isDevelopment = url.hostname === "127.0.0.1" || isLocalhostOrIpAddress;
59
63
  return isDevelopment;
60
64
  }
65
+ /**
66
+ * A promise queue that limits the number of concurrent promises.
67
+ * Use the `slot` method to request a slot for a promise with a specific key. The returned promise resolves to an object with a `use` method that can be called to add the promise to the queue.
68
+ */
61
69
  export class PromiseQueue {
62
70
  maxConcurrent;
63
71
  _running = new Map();
package/lib/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // replaced at build time
2
- export const version = "3.3.2";
2
+ export const version = "3.3.3";
3
3
  globalThis["GLTF_PROGRESSIVE_VERSION"] = version;
4
4
  console.debug(`[gltf-progressive] version ${version || "-"}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@needle-tools/gltf-progressive",
3
- "version": "3.3.2",
3
+ "version": "3.3.3-next.ff6503a",
4
4
  "description": "three.js support for loading glTF or GLB files that contain progressive loading data",
5
5
  "homepage": "https://needle.tools",
6
6
  "author": {
@@ -40,7 +40,8 @@
40
40
  "CHANGELOG.md",
41
41
  "gltf-progressive.js",
42
42
  "gltf-progressive.min.js",
43
- "gltf-progressive.umd.cjs"
43
+ "gltf-progressive.umd.cjs",
44
+ "NEEDLE_progressive"
44
45
  ],
45
46
  "watch": {
46
47
  "build:lib": {
@@ -72,4 +73,4 @@
72
73
  "vite": "7"
73
74
  },
74
75
  "types": "./lib/index.d.ts"
75
- }
76
+ }