@xeokit/xeokit-sdk 2.6.75 → 2.6.77-slim-rc2

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.
Files changed (33) hide show
  1. package/dist/xeokit-sdk.cjs.js +28 -21
  2. package/dist/xeokit-sdk.es.js +28 -21
  3. package/dist/xeokit-sdk.es5.js +9 -9
  4. package/dist/xeokit-sdk.min.cjs.js +8 -8
  5. package/dist/xeokit-sdk.min.es.js +8 -8
  6. package/dist/xeokit-sdk.min.es5.js +7 -7
  7. package/package.json +2 -3
  8. package/src/extras/Skybox/Skybox.js +139 -0
  9. package/src/extras/index.js +2 -1
  10. package/src/plugins/CxConverterIFCLoaderPlugin/CxConverterIFCLoaderPlugin.js +81 -81
  11. package/src/plugins/CxConverterIFCLoaderPlugin/index.js +1 -1
  12. package/src/plugins/FastNavPlugin/FastNavPlugin.js +0 -18
  13. package/src/plugins/SectionPlanesPlugin/Control.js +1 -1
  14. package/src/plugins/index.js +0 -1
  15. package/src/viewer/scene/camera/CameraFlightAnimation.js +2 -2
  16. package/src/viewer/scene/canvas/Canvas.js +7 -4
  17. package/src/viewer/scene/index.js +0 -1
  18. package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesColorRenderer.js +5 -0
  19. package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesColorRenderer.js +5 -0
  20. package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesFlatColorRenderer.js +5 -0
  21. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesColorRenderer.js +5 -0
  22. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesFlatColorRenderer.js +5 -0
  23. package/types/plugins/FastNavPlugin/FastNavPlugin.d.ts +5 -0
  24. package/types/plugins/index.d.ts +0 -1
  25. package/types/viewer/scene/index.d.ts +0 -1
  26. package/src/plugins/SkyboxesPlugin/SkyboxesPlugin.js +0 -109
  27. package/src/plugins/SkyboxesPlugin/index.js +0 -1
  28. package/src/viewer/scene/skybox/Skybox.js +0 -224
  29. package/types/plugins/SkyboxesPlugin/SkyboxesPlugin.d.ts +0 -48
  30. package/types/plugins/SkyboxesPlugin/index.d.ts +0 -1
  31. package/types/viewer/scene/skybox/Skybox.d.ts +0 -59
  32. package/types/viewer/scene/skybox/index.d.ts +0 -1
  33. /package/src/{viewer/scene/skybox → extras/Skybox}/index.js +0 -0
@@ -1,109 +0,0 @@
1
- import {Plugin} from "../../viewer/Plugin.js";
2
- import {Skybox} from "../../viewer/scene/skybox/Skybox.js"
3
-
4
- /**
5
- * {@link Viewer} plugin that manages skyboxes
6
- *
7
- * @example
8
- *
9
- * // Create a Viewer
10
- * const viewer = new Viewer({
11
- * canvasId: "myCanvas"
12
- * });
13
- *
14
- * // Add a GLTFModelsPlugin
15
- * var xktLoaderPlugin = new XKTLoaderPlugin(viewer);
16
- *
17
- * // Add a SkyboxesPlugin
18
- * var skyboxesPlugin = new SkyboxesPlugin(viewer);
19
- *
20
- * // Create a skybox
21
- * skyBoxesPlugin.createSkybox({
22
- * src: [
23
- * "./assets/images/posx.jpg",
24
- * "./assets/images/negx.jpg",
25
- * "./assets/images/posy.jpg",
26
- * "./assets/images/negy.jpg",
27
- * "./assets/images/posz.jpg",
28
- * "./assets/images/negz.jpg"
29
- * ]
30
- * })
31
- *
32
- * // Load an XKT model
33
- * const model = xktLoaderPlugin.load({
34
- * id: "myModel",
35
- * src: "./models/xkt/myModel.xkt"
36
- * });
37
- *
38
- * @class SkyboxesPlugin
39
- */
40
- class SkyboxesPlugin extends Plugin {
41
-
42
- constructor(viewer) {
43
- super("skyboxes", viewer);
44
- this.skyboxes = {};
45
- }
46
-
47
- /**
48
- * @private
49
- */
50
- send(name, value) {
51
- switch (name) {
52
- case "clear":
53
- this.clear();
54
- break;
55
- }
56
- }
57
-
58
- /**
59
- Creates a skybox.
60
-
61
- @param {Object} params Skybox configuration.
62
- @param {String} [params.id] Optional ID, unique among all components in the parent {Scene}, generated automatically when omitted.
63
- @param {String | String[]} [params.src=null] Path to skybox texture
64
- @param {Number} [params.encoding=LinearEncoding] Texture encoding format. See the {@link Texture#encoding} property for more info.
65
- @param {Number} [params.size=1000] Size of this Skybox, given as the distance from the center at ````[0,0,0]```` to each face.
66
- @param {Boolean} [params.active=true] Whether the skybox plane is initially active. Only skyboxes while this is true.
67
- @returns {Skybox} The new skybox.
68
- */
69
- createSkybox(params) {
70
- const skybox = new Skybox(this.viewer.scene, params);
71
- this.skyboxes[skybox.id] = skybox;
72
- return skybox;
73
- }
74
-
75
- /**
76
- Destroys a skybox.
77
- @param id
78
- */
79
- destroySkybox(id) {
80
- var skybox = this.skyboxes[id];
81
- if (!skybox) {
82
- this.error("Skybox not found: " + id);
83
- return;
84
- }
85
- skybox.destroy();
86
- }
87
-
88
- /**
89
- Destroys all skyboxes.
90
- */
91
- clear() {
92
- var ids = Object.keys(this.viewer.scene.skyboxes);
93
- for (var i = 0, len = ids.length; i < len; i++) {
94
- this.destroySkybox(ids[i]);
95
- }
96
- }
97
-
98
- /**
99
- * Destroys this plugin.
100
- *
101
- * Clears skyboxes from the Viewer first.
102
- */
103
- destroy() {
104
- this.clear();
105
- super.clear();
106
- }
107
- }
108
-
109
- export {SkyboxesPlugin}
@@ -1 +0,0 @@
1
- export * from "./SkyboxesPlugin.js";
@@ -1,224 +0,0 @@
1
- import {Component} from "../Component.js";
2
- import {Mesh} from "../mesh/Mesh.js";
3
- import {ReadableGeometry} from "../geometry/ReadableGeometry.js";
4
- import {PhongMaterial} from "../materials/PhongMaterial.js";
5
- import {Texture} from "../materials/Texture.js";
6
- import { ClampToEdgeWrapping, LinearEncoding } from "../constants/constants.js";
7
-
8
- /**
9
- * @desc A Skybox.
10
- */
11
- class Skybox extends Component {
12
-
13
- /**
14
- * @constructor
15
- * @param {Component} owner Owner component. When destroyed, the owner will destroy this PointLight as well.
16
- * @param {*} [cfg] Skybox configuration
17
- * @param {String} [cfg.id] Optional ID, unique among all components in the parent {Scene}, generated automatically when omitted.
18
- * @param {String | String[]} [cfg.src=null] Path to skybox texture
19
- * @param {Number} [cfg.encoding=LinearEncoding] Texture encoding format. See the {@link Texture#encoding} property for more info.
20
- * @param {Number} [cfg.size=1000] Size of this Skybox, given as the distance from the center at ````[0,0,0]```` to each face.
21
- * @param {Boolean} [cfg.active=true] True when this Skybox is visible.
22
- */
23
- constructor(owner, cfg = {}) {
24
-
25
- super(owner, cfg);
26
-
27
- const useMultipleTexture = typeof cfg.src === "object" && cfg.src !== null;
28
-
29
- if (useMultipleTexture) {
30
- this._createCombinedTexture(cfg).then(combinedTexture => {
31
- this._createSkyboxMesh(cfg, combinedTexture);
32
- }).catch(e => this.error(e));
33
- } else {
34
- this._createSkyboxMesh(cfg);
35
- }
36
- }
37
-
38
- /**
39
- *
40
- * @private
41
- * @param {*} cfg
42
- * @param {Texture} combinedTexture
43
- */
44
- _createSkyboxMesh(cfg, combinedTexture = null) {
45
- const texture = combinedTexture || new Texture(this, {
46
- src: cfg.src,
47
- flipY: true,
48
- wrapS: ClampToEdgeWrapping,
49
- wrapT: ClampToEdgeWrapping,
50
- encoding: cfg.encoding || LinearEncoding
51
- });
52
-
53
- this._skyboxMesh = new Mesh(this, {
54
-
55
- geometry: new ReadableGeometry(this, { // Box-shaped geometry
56
- primitive: "triangles",
57
- positions: [
58
- 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, // v0-v1-v2-v3 front
59
- 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, // v0-v3-v4-v5 right
60
- 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, // v0-v5-v6-v1 top
61
- -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, // v1-v6-v7-v2 left
62
- -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, // v7-v4-v3-v2 bottom
63
- 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1 // v4-v7-v6-v5 back
64
- ],
65
- uv: [
66
- 0.5, 0.6666, 0.25, 0.6666, 0.25, 0.3333, 0.5, 0.3333, 0.5, 0.6666, 0.5, 0.3333, 0.75, 0.3333, 0.75, 0.6666,
67
- 0.5, 0.6666, 0.5, 1, 0.25, 1, 0.25, 0.6666, 0.25, 0.6666, 0.0, 0.6666, 0.0, 0.3333, 0.25, 0.3333,
68
- 0.25, 0, 0.50, 0, 0.50, 0.3333, 0.25, 0.3333, 0.75, 0.3333, 1.0, 0.3333, 1.0, 0.6666, 0.75, 0.6666
69
- ],
70
- indices: [
71
- 0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8, 10, 11,
72
- 12, 13, 14, 12, 14, 15, 16, 17, 18, 16, 18, 19, 20, 21, 22, 20, 22, 23
73
- ]
74
- }),
75
- background: true,
76
- scale: [2000, 2000, 2000], // Overridden when we initialize the 'size' property, below
77
- rotation: [0, -90, 0],
78
- material: new PhongMaterial(this, {
79
- ambient: [0, 0, 0],
80
- diffuse: [0, 0, 0],
81
- specular: [0, 0, 0],
82
- emissive: [1, 1, 1],
83
- emissiveMap: texture,
84
- backfaces: true // Show interior faces of our skybox geometry
85
- }),
86
- // stationary: true,
87
- visible: false,
88
- pickable: false,
89
- clippable: false,
90
- collidable: false
91
- });
92
-
93
- this.size = cfg.size; // Sets 'xyz' property on the Mesh's Scale transform
94
- this.active = cfg.active;
95
- }
96
-
97
- /**
98
- *
99
- * @private
100
- * @param {*} cfg
101
- * @returns {Texture}
102
- */
103
- async _createCombinedTexture(cfg) {
104
- const [
105
- posX,
106
- negX,
107
- posY,
108
- negY,
109
- posZ,
110
- negZ
111
- ] = cfg.src;
112
-
113
- if (!posX || !negX || !posY || !negY || !posZ || !negZ) {
114
- throw new Error("All six skybox textures must be provided");
115
- }
116
-
117
- const canvas = document.createElement('canvas');
118
- const ctx = canvas.getContext('2d');
119
-
120
- const loadImage = src => {
121
- return new Promise((resolve, reject) => {
122
- const img = new Image();
123
- img.crossOrigin = "anonymous";
124
- img.onload = () => resolve(img);
125
- img.onerror = () => reject(new Error(`Failed to load image: ${src}`));
126
- img.src = src;
127
- });
128
- };
129
-
130
- try {
131
- const [imgPosX, imgNegX, imgPosY, imgNegY, imgPosZ, imgNegZ] = await Promise.all([
132
- loadImage(posX),
133
- loadImage(negX),
134
- loadImage(posY),
135
- loadImage(negY),
136
- loadImage(posZ),
137
- loadImage(negZ)
138
- ]);
139
-
140
- const imageSize = imgPosX.width;
141
- if (
142
- imgNegX.width !== imageSize || imgPosY.width !== imageSize ||
143
- imgNegY.width !== imageSize || imgPosZ.width !== imageSize ||
144
- imgNegZ.width !== imageSize
145
- ) {
146
- throw new Error("All skybox textures must have the same dimensions");
147
- }
148
-
149
- // Set canvas size for the Christ cross layout (3×4 grid)
150
- canvas.width = imageSize * 4;
151
- canvas.height = imageSize * 3;
152
-
153
- ctx.fillStyle = 'black';
154
- ctx.fillRect(0, 0, canvas.width, canvas.height);
155
-
156
- ctx.drawImage(imgNegX, imageSize * 0, imageSize * 1, imageSize, imageSize); // -X (left)
157
- ctx.drawImage(imgPosX, imageSize * 2, imageSize * 1, imageSize, imageSize); // +X (right)
158
- ctx.drawImage(imgPosY, imageSize * 1, imageSize * 0, imageSize, imageSize); // +Y (top)
159
- ctx.drawImage(imgNegY, imageSize * 1, imageSize * 2, imageSize, imageSize); // -Y (bottom)
160
- ctx.drawImage(imgPosZ, imageSize * 1, imageSize * 1, imageSize, imageSize); // +Z (front)
161
- ctx.drawImage(imgNegZ, imageSize * 3, imageSize * 1, imageSize, imageSize); // -Z (back)
162
-
163
- const combinedTexture = new Texture(this, {
164
- image: canvas,
165
- flipY: true,
166
- wrapS: ClampToEdgeWrapping,
167
- wrapT: ClampToEdgeWrapping,
168
- encoding: cfg.encoding || LinearEncoding
169
- });
170
-
171
- return combinedTexture;
172
- } catch (error) {
173
- console.error("Error creating combined skybox texture:", error);
174
- throw error;
175
- }
176
- }
177
-
178
- /**
179
- * Sets the size of this Skybox, given as the distance from the center at [0,0,0] to each face.
180
- *
181
- * Default value is ````1000````.
182
- *
183
- * @param {Number} value The size.
184
- */
185
- set size(value) {
186
- this._size = value || 1000;
187
- this._skyboxMesh.scale = [this._size, this._size, this._size];
188
- }
189
-
190
- /**
191
- * Gets the size of this Skybox, given as the distance from the center at [0,0,0] to each face.
192
- *
193
- * Default value is ````1000````.
194
- *
195
- * @returns {Number} The size.
196
- */
197
- get size() {
198
- return this._size;
199
- }
200
-
201
- /**
202
- * Sets whether this Skybox is visible or not.
203
- *
204
- * Default value is ````true````.
205
- *
206
- * @param {Boolean} active Whether to make active or not.
207
- */
208
- set active(active) {
209
- this._skyboxMesh.visible = active;
210
- }
211
-
212
- /**
213
- * Gets if this Skybox is visible or not.
214
- *
215
- * Default active is ````true````.
216
- *
217
- * @returns {Boolean} ````true```` if the Skybox is active.
218
- */
219
- get active() {
220
- return this._skyboxMesh.visible;
221
- }
222
- }
223
-
224
- export {Skybox}
@@ -1,48 +0,0 @@
1
- import { Plugin, Viewer, Skybox } from "../../viewer";
2
-
3
- /**
4
- * {@link Viewer} plugin that manages skyboxes
5
- */
6
- export declare class SkyboxesPlugin extends Plugin {
7
- /**
8
- * @constructor
9
- * @param {Viewer} viewer The Viewer.
10
- */
11
- constructor(viewer: Viewer);
12
-
13
- /**
14
- * Creates a skybox.
15
- * @param {Object} params Skybox configuration.
16
- * @param {String} [params.id] Optional ID, unique among all components in the parent {Scene}, generated automatically when omitted.
17
- * @param {String | String[]} [params.src=null] Path to skybox texture
18
- * @param {Number} [params.encoding=LinearEncoding] Texture encoding format. See the {@link Texture#encoding} property for more info.
19
- * @param {Number} [params.size=1000] Size of this Skybox, given as the distance from the center at ````[0,0,0]```` to each face.
20
- * @param {Boolean} [params.active=true] Whether the skybox plane is initially active. Only skyboxes while this is true.
21
- * @returns {Skybox} The new skybox.
22
- */
23
- createSkybox(params: {
24
- id?: string,
25
- src: string | string[],
26
- encoding?: number,
27
- size?: number,
28
- active?: boolean;
29
- }): Skybox; //Skybox;
30
-
31
- /**
32
- * Destroys a skybox.
33
- * @param id
34
- */
35
- destroySkybox(id: string): void;
36
-
37
- /**
38
- Destroys all skyboxes.
39
- */
40
- clear(): void;
41
-
42
- /**
43
- * Destroys this plugin.
44
- *
45
- * Clears skyboxes from the Viewer first.
46
- */
47
- destroy(): void;
48
- }
@@ -1 +0,0 @@
1
- export * from "./SkyboxesPlugin";
@@ -1,59 +0,0 @@
1
- import { Component } from '../Component';
2
-
3
- export declare type SkyboxConfiguration = {
4
- /** Optional ID, unique among all components in the parent {Scene}, generated automatically when omitted. */
5
- id?: string;
6
- /** Path to skybox texture */
7
- src: string | string[];
8
- /** Texture encoding format. See the {@link Texture#encoding} property for more info. */
9
- encoding?: number;
10
- /** Size of this Skybox, given as the distance from the center at ````[0,0,0]```` to each face. */
11
- size?: number;
12
- /** True when this Skybox is visible. */
13
- active?: boolean;
14
- }
15
-
16
- export declare class Skybox extends Component {
17
- /**
18
- * @constructor
19
- * @param {Component} owner Owner component. When destroyed, the owner will destroy this PointLight as well.
20
- * @param {SkyboxConfiguration} [cfg] Skybox configuration
21
- */
22
- constructor(owner: Component, cfg?: SkyboxConfiguration);
23
-
24
- /**
25
- * Sets the size of this Skybox, given as the distance from the center at [0,0,0] to each face.
26
- *
27
- * Default value is ````1000````.
28
- *
29
- * @param {Number} value The size.
30
- */
31
- set size(value: number);
32
-
33
- /**
34
- * Gets the size of this Skybox, given as the distance from the center at [0,0,0] to each face.
35
- *
36
- * Default value is ````1000````.
37
- *
38
- * @returns {Number} The size.
39
- */
40
- get size(): number;
41
-
42
- /**
43
- * Sets whether this Skybox is visible or not.
44
- *
45
- * Default value is ````true````.
46
- *
47
- * @param {Boolean} active Whether to make active or not.
48
- */
49
- set active(active: boolean);
50
-
51
- /**
52
- * Gets if this Skybox is visible or not.
53
- *
54
- * Default active is ````true````.
55
- *
56
- * @returns {Boolean} ````true```` if the Skybox is active.
57
- */
58
- get active(): boolean;
59
- }
@@ -1 +0,0 @@
1
- export * from './Skybox';