Skip to content

Commit

Permalink
Merge pull request #105 from pattern-x/feature/update-demo
Browse files Browse the repository at this point in the history
Update some demo pages
  • Loading branch information
pattern-x committed Jul 15, 2023
2 parents 19f360c + d4fe390 commit 4644d13
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 84 deletions.
3 changes: 3 additions & 0 deletions public/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
}, {
"title": "Overlay 3d model with dxf",
"url": "./demo/bim_2_overlay_with_dxf.html"
}, {
"title": "Model explode",
"url": "./demo/bim_3_explode.html"
}]
}, {
"title": "2D drawings",
Expand Down
53 changes: 17 additions & 36 deletions public/demo/bim_0.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,18 @@
ToolbarMenuId,
} from "./demo/libs/gemini-viewer.esm.min.js";

const project = {
"id": "rac_basic_sample_project",
"name": "Rac basic sample project",
"camera": {
"eye": [-70, 25, 50],
"look": [-35, 0, 35],
"up": [0, 1, 0],
"far": 10000
},
"models": [{
"name": "Rac basic sample project",
"src": "./demo/models/gltf/rac_basic_sample_project.gltf",
"position": [0, 0, 0],
"rotation": [0, 0, 0],
"scale": [1, 1, 1],
"edges": true,
"visible": true
}]
}
const viewer = new BimViewer({
const filename = "rac_basic_sample_project.gltf";
const modelCfg = {
modelId: filename,
name: filename,
src: `./demo/models/gltf/${filename}`,
edges: true,
};
const viewerCfg = {
containerId: "myCanvas",
}, project.camera);
language: "en",
}
const viewer = new BimViewer(viewerCfg);
const toolbar = viewer.toolbar;
toolbar.updateMenu(ToolbarMenuId.BimTree, { visible: false });

Expand All @@ -60,21 +50,12 @@
const decoderPath = "./demo/three/js/libs/draco/gltf/";
viewer.setDracoDecoderPath(decoderPath);

// loadProjectModel
let counter = 0; // to indicate how many models are loading
project.models.forEach((modelCfg) => {
if (modelCfg.visible === false) {
// visible is true by default
return; // only load visible ones
}
counter++;
viewer.loadModel(modelCfg, (event) => {
console.log(`[Demo] Loading model ${modelCfg.src}`);
}, (event) => {
console.error("[Demo] Failed to load " + modelCfg.src + ". " + event.message);
}).then(() => {
console.log(`[Demo] Loaded model ${modelCfg.src}`);
});
viewer.loadModel(modelCfg, (event) => {
console.log(`[Demo] Loading model ${modelCfg.src}`);
}, (event) => {
console.error("[Demo] Failed to load " + modelCfg.src + ". " + event.message);
}).then(() => {
console.log(`[Demo] Loaded model ${modelCfg.src}`);
});
</script>
</body>
Expand Down
66 changes: 22 additions & 44 deletions public/demo/bim_1.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,36 +25,24 @@
ToolbarMenuId,
} from "./demo/libs/gemini-viewer.esm.min.js";

const project = {
id: "Duplex",
name: "Duplex",
models: [
{
name: "Duplex",
src: "./demo/models/gltf/Duplex.gltf",
position: [0, 0, 0],
rotation: [0, 0, 0],
scale: [1, 1, 1],
instantiate: false,
merge: false,
edges: true,
visible: true,
},
],
const filename = "Duplex.gltf";
const modelCfg = {
modelId: filename,
name: filename,
src: `./demo/models/gltf/${filename}`,
edges: true,
};
const viewer = new BimViewer(
{
containerId: "myCanvas",
language: "en",
toolbarMenuConfig: {
[ToolbarMenuId.Measure]: { visible: false },
[ToolbarMenuId.Fullscreen]: { visible: false },
[ToolbarMenuId.BimTree]: { visible: false },
},
enableContextMenu: true,
const viewerCfg = {
containerId: "myCanvas",
language: "en",
toolbarMenuConfig: {
[ToolbarMenuId.Measure]: { visible: false },
[ToolbarMenuId.Fullscreen]: { visible: false },
[ToolbarMenuId.BimTree]: { visible: false },
},
project.camera
);
enableContextMenu: true,
}
const viewer = new BimViewer(viewerCfg);

new AxisGizmoPlugin(viewer);
new BottomBarPlugin(viewer);
Expand All @@ -66,22 +54,12 @@
const decoderPath = "./demo/three/js/libs/draco/gltf/";
viewer.setDracoDecoderPath(decoderPath);

// loadProjectModel
let counter = 0; // to indicate how many models are loading
project.models.forEach((modelCfg) => {
if (modelCfg.visible === false) {
// visible is true by default
return; // only load visible ones
}
counter++;
viewer.loadModel(modelCfg, (event) => {
console.log(`[Demo] Loading model ${modelCfg.src}`);
}, (event) => {
console.error("[Demo] Failed to load " + modelCfg.src + ". " + event.message);
}
).then(() => {
console.log(`[Demo] Loaded model ${modelCfg.src}`);
});
viewer.loadModel(modelCfg, (event) => {
console.log(`[Demo] Loading model ${modelCfg.src}`);
}, (event) => {
console.error("[Demo] Failed to load " + modelCfg.src + ". " + event.message);
}).then(() => {
console.log(`[Demo] Loaded model ${modelCfg.src}`);
});
</script>
</body>
Expand Down
5 changes: 1 addition & 4 deletions public/demo/bim_2_overlay_with_dxf.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
}
const viewer = new BimViewer({
containerId: "myCanvas",
}, project.camera);
});
const toolbar = viewer.toolbar;
toolbar.updateMenu(ToolbarMenuId.BimTree, { visible: false });

Expand All @@ -68,14 +68,11 @@
const decoderPath = "./demo/three/js/libs/draco/gltf/";
viewer.setDracoDecoderPath(decoderPath);

// loadProjectModel
let counter = 0; // to indicate how many models are loading
project.models.forEach((modelCfg) => {
if (modelCfg.visible === false) {
// visible is true by default
return; // only load visible ones
}
counter++;
viewer.loadModel(modelCfg, (event) => {
console.log(`[Demo] Loading model ${modelCfg.src}`);
}, (event) => {
Expand Down

0 comments on commit 4644d13

Please sign in to comment.