Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/xeokit/xeokit-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
xeolabs committed Mar 27, 2024
2 parents b1abd30 + 0ac49dc commit 84383f8
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 3 deletions.
1 change: 1 addition & 0 deletions examples/emphasising/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@
["highlight_transparentCanvas", "Click objects to highlight them (with transparent canvas)"],
["select", "Click objects to make them appear selected"],
["select_glowThroughFalse", "Click objects to select them (with glowThroughFalse)"],
["select_glowThroughFalse_dtx", "Click objects to select them (with glowThroughFalse, dtx)"],
["select_transparentCanvas", "Click objects to select them (with transparent canvas)"],
["xray", "Click objects to X-ray them"],
["xray_transparentCanvas", "Click objects to X-ray them (with transparent canvas)"]
Expand Down
5 changes: 3 additions & 2 deletions examples/emphasising/select_glowThroughFalse.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@ <h3>Components Used</h3>
// Import the modules we need for this example
//------------------------------------------------------------------------------------------------------------------

import {Viewer, XKTLoaderPlugin} from "../../dist/xeokit-sdk.min.es.js";
import {Viewer, XKTLoaderPlugin} from "../../dist/xeokit-sdk.es.js";

//------------------------------------------------------------------------------------------------------------------
// Create a Viewer
//------------------------------------------------------------------------------------------------------------------

const viewer = new Viewer({
canvasId: "myCanvas",
transparent: true
transparent: true,
dtxEnabled: true
});

viewer.camera.eye = [-3.93, 2.85, 27.01];
Expand Down
91 changes: 91 additions & 0 deletions examples/emphasising/select_glowThroughFalse_dtx.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>xeokit Example</title>
<link href="../css/pageStyle.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/js/all.min.js"></script>
</head>
<body>
<input type="checkbox" id="info-button"/>
<label for="info-button" class="info-button"><i class="far fa-3x fa-question-circle"></i></label>
<canvas id="myCanvas"></canvas>
<div class="slideout-sidebar">
<h1>Picking Objects</h1>
<h2>Hover over objects to select them</h2>
<p>In this example, we've set glowThrough:false on the Scene's HighlightMaterial. This disables the usual "glow-through" behaviour for selected objects.</p>
<h3>Components Used</h3>
<ul>
<li>
<a href="../../docs/class/src/viewer/Viewer.js~Viewer.html"
target="_other">Viewer</a>
</li>
<li>
<a href="../../docs/class/src/plugins/XKTLoaderPlugin/XKTLoaderPlugin.js~XKTLoaderPlugin.html"
target="_other">XKTLoaderPlugin</a>
</li>
</ul>
</div>
</body>
<script type="module">

//------------------------------------------------------------------------------------------------------------------
// Import the modules we need for this example
//------------------------------------------------------------------------------------------------------------------

import {Viewer, XKTLoaderPlugin} from "../../dist/xeokit-sdk.es.js";

//------------------------------------------------------------------------------------------------------------------
// Create a Viewer
//------------------------------------------------------------------------------------------------------------------

const viewer = new Viewer({
canvasId: "myCanvas",
transparent: true,
dtxEnabled: true
});

viewer.camera.eye = [-3.93, 2.85, 27.01];
viewer.camera.look = [4.40, 3.72, 8.89];
viewer.camera.up = [-0.01, 0.99, 0.039];

//------------------------------------------------------------------------------------------------------------------
// Disable glow-through effect on the "selected" effect material.
// It also seems best to make objects opaque when selected.
//------------------------------------------------------------------------------------------------------------------

viewer.scene.selectedMaterial.glowThrough = false;
viewer.scene.selectedMaterial.fillAlpha = 1.0;
viewer.scene.selectedMaterial.edgeAlpha = 1.0;

//------------------------------------------------------------------------------------------------------------------
// Load a model
//------------------------------------------------------------------------------------------------------------------

const xktLoader = new XKTLoaderPlugin(viewer);

const sceneModel = xktLoader.load({
id: "myModel",
src: "../../assets/models/xkt/v10/glTF-Embedded/Duplex_A_20110505.glTFEmbedded.xkt",
edges: true
});

//------------------------------------------------------------------------------------------------------------------
//Click Entities to make them appear selected
//------------------------------------------------------------------------------------------------------------------

viewer.scene.input.on("mousedown", function (coords) {

const pickResult = viewer.scene.pick({
canvasPos: coords
});

if (pickResult) {
console.log(pickResult.entity.id);
pickResult.entity.selected = true;
}
});
</script>
</html>
4 changes: 3 additions & 1 deletion src/viewer/scene/model/dtx/triangles/DTXTrianglesLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,9 @@ export class DTXTrianglesLayer {
// Color

let f0;
if (!visible || culled || xrayed) { // Highlight & select are layered on top of color - not mutually exclusive
if (!visible || culled || xrayed
|| (highlighted && !this.model.scene.highlightMaterial.glowThrough)
|| (selected && !this.model.scene.selectedMaterial.glowThrough)) {
f0 = RENDER_PASSES.NOT_RENDERED;
} else {
if (transparent) {
Expand Down

0 comments on commit 84383f8

Please sign in to comment.