Skip to content

Commit

Permalink
Merge pull request #1680 from xeokit/XCD-159-globalize-gltf-id
Browse files Browse the repository at this point in the history
XCD-159 Optionally globalize GLTF's entityId
  • Loading branch information
xeolabs authored Sep 24, 2024
2 parents eebb4fd + 480c0e2 commit b486f79
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 27 deletions.
18 changes: 13 additions & 5 deletions dist/xeokit-sdk.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -110476,10 +110476,14 @@ class Viewer {

for (let i = 0, len = pluginContainerElements.length; i < len; i++) {
const containerElement = pluginContainerElements[i];
//only calculate the scale for first plugin
//for all others keep the scale 1 otherwise it will keep multiplying the scale with the base scale of canvas
//resulting in increase/decreased size for the the canvas that is being overlapped
const scale = i == 0 ? snapshotCanvas.width / containerElement.clientWidth : 1;
await html2canvas(containerElement, {
canvas: snapshotCanvas,
backgroundColor: null,
scale: snapshotCanvas.width / containerElement.clientWidth
scale
});
}
if (!params.includeGizmos) {
Expand Down Expand Up @@ -117990,6 +117994,7 @@ function parseGLTF(plugin, src, gltf, metaModelJSON, options, sceneModel, ok) {
entityId: options.entityId,
metaModelJSON,
autoMetaModel: options.autoMetaModel,
globalizeObjectIds: options.globalizeObjectIds,
metaObjects: [],
loadBuffer: options.loadBuffer,
basePath: options.basePath,
Expand Down Expand Up @@ -118318,16 +118323,17 @@ function loadDefaultScene(ctx) {

if (entityId) {
if (meshIds.length > 0) {
const globalId = ctx.globalizeObjectIds ? math.globalizeObjectId(ctx.sceneModel.id, entityId) : entityId;
ctx.sceneModel.createEntity({
id: entityId,
id: globalId,
meshIds: meshIds,
isObject: true
});
if (ctx.autoMetaModel) {
ctx.metaObjects.push({
id: entityId,
id: globalId,
type: "Default",
name: entityId,
name: globalId,
parent: ctx.sceneModel.id
});
}
Expand Down Expand Up @@ -118810,6 +118816,7 @@ class GLTFLoaderPlugin extends Plugin {
* to non-textured triangle meshes, and that VBOs are always used for meshes that have textures, line segments, or point
* primitives. Only works while {@link DTX#enabled} is also ````true````.
* @param {Boolean} [params.autoMetaModel] When supplied, creates a default MetaModel with a single MetaObject.
* @param {Boolean} [params.globalizeObjectIds=false] Indicates whether to globalize each {@link Entity#id} and {@link MetaObject#id}, in case you need to prevent ID clashes with other models.
* @returns {Entity} Entity representing the model, which will have {@link Entity#isModel} set ````true```` and will be registered by {@link Entity#id} in {@link Scene#models}
*/
load(params = {}) {
Expand Down Expand Up @@ -140178,7 +140185,8 @@ class DotBIMLoaderPlugin extends Plugin {
}
metaModelData.propertySets.push({
id: objectId,
properties
name: "Properties",
properties: properties
});

metaModelData.metaObjects.push({
Expand Down
18 changes: 13 additions & 5 deletions dist/xeokit-sdk.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -110472,10 +110472,14 @@ class Viewer {

for (let i = 0, len = pluginContainerElements.length; i < len; i++) {
const containerElement = pluginContainerElements[i];
//only calculate the scale for first plugin
//for all others keep the scale 1 otherwise it will keep multiplying the scale with the base scale of canvas
//resulting in increase/decreased size for the the canvas that is being overlapped
const scale = i == 0 ? snapshotCanvas.width / containerElement.clientWidth : 1;
await html2canvas(containerElement, {
canvas: snapshotCanvas,
backgroundColor: null,
scale: snapshotCanvas.width / containerElement.clientWidth
scale
});
}
if (!params.includeGizmos) {
Expand Down Expand Up @@ -117986,6 +117990,7 @@ function parseGLTF(plugin, src, gltf, metaModelJSON, options, sceneModel, ok) {
entityId: options.entityId,
metaModelJSON,
autoMetaModel: options.autoMetaModel,
globalizeObjectIds: options.globalizeObjectIds,
metaObjects: [],
loadBuffer: options.loadBuffer,
basePath: options.basePath,
Expand Down Expand Up @@ -118314,16 +118319,17 @@ function loadDefaultScene(ctx) {

if (entityId) {
if (meshIds.length > 0) {
const globalId = ctx.globalizeObjectIds ? math.globalizeObjectId(ctx.sceneModel.id, entityId) : entityId;
ctx.sceneModel.createEntity({
id: entityId,
id: globalId,
meshIds: meshIds,
isObject: true
});
if (ctx.autoMetaModel) {
ctx.metaObjects.push({
id: entityId,
id: globalId,
type: "Default",
name: entityId,
name: globalId,
parent: ctx.sceneModel.id
});
}
Expand Down Expand Up @@ -118806,6 +118812,7 @@ class GLTFLoaderPlugin extends Plugin {
* to non-textured triangle meshes, and that VBOs are always used for meshes that have textures, line segments, or point
* primitives. Only works while {@link DTX#enabled} is also ````true````.
* @param {Boolean} [params.autoMetaModel] When supplied, creates a default MetaModel with a single MetaObject.
* @param {Boolean} [params.globalizeObjectIds=false] Indicates whether to globalize each {@link Entity#id} and {@link MetaObject#id}, in case you need to prevent ID clashes with other models.
* @returns {Entity} Entity representing the model, which will have {@link Entity#isModel} set ````true```` and will be registered by {@link Entity#id} in {@link Scene#models}
*/
load(params = {}) {
Expand Down Expand Up @@ -140174,7 +140181,8 @@ class DotBIMLoaderPlugin extends Plugin {
}
metaModelData.propertySets.push({
id: objectId,
properties
name: "Properties",
properties: properties
});

metaModelData.metaObjects.push({
Expand Down
Loading

0 comments on commit b486f79

Please sign in to comment.