Skip to content

Commit

Permalink
Rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
xeolabs committed Dec 30, 2024
1 parent bb557c8 commit 98913a0
Show file tree
Hide file tree
Showing 6 changed files with 304 additions and 174 deletions.
144 changes: 104 additions & 40 deletions dist/xeokit-sdk.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -784,12 +784,19 @@ class ContextMenu {
subMenuElement.getBoundingClientRect();

const subMenuWidth = 200; // TODO
const showOnLeft = ((itemRect.right + subMenuWidth) > window.innerWidth);
const showOnRight = (itemRect.right + subMenuWidth) < window.innerWidth;
const showOnLeft = (itemRect.left - subMenuWidth) > 0;

if (showOnLeft) {
self._showMenu(subMenu.id, itemRect.left - subMenuWidth, itemRect.top - 1);
} else {
if(showOnRight)
self._showMenu(subMenu.id, itemRect.right - 5, itemRect.top - 1);
else if (showOnLeft)
self._showMenu(subMenu.id, itemRect.left - subMenuWidth, itemRect.top - 1);
else {
const spaceOnLeft = itemRect.left, spaceOnRight = window.innerWidth - itemRect.right;
if(spaceOnRight > spaceOnLeft)
self._showMenu(subMenu.id, itemRect.right - 5 - (subMenuWidth - spaceOnRight), itemRect.top - 1);
else
self._showMenu(subMenu.id, itemRect.left - spaceOnLeft, itemRect.top - 1);
}

lastSubMenu = subMenu;
Expand Down Expand Up @@ -9593,14 +9600,17 @@ function addContextMenuListener(elem, callback) {

const touchStartHandler = (event) => {
event.preventDefault();
const touch = event.touches[0];
startX = touch.clientX;
startY = touch.clientY;


if (timeout) {
clearTimeout(timeout);
timeout = null;
}
// If more than one finger touches the screen, cancel the timeout
if (event.touches.length > 1) return;

const touch = event.touches[0];
startX = touch.clientX;
startY = touch.clientY;

timeout = setTimeout(() => {
event.clientX = touch.clientX;
Expand All @@ -9611,6 +9621,14 @@ function addContextMenuListener(elem, callback) {
}, longPressTimer);
};

const globalTouchStartHandler = (event) => {
// Cancel timeout if multiple touches are detected anywhere on the screen
if (event.touches.length > 1 && timeout) {
clearTimeout(timeout);
timeout = null;
}
};

const touchMoveHandler = (event) => {
if (!timeout) return;
const touch = event.touches[0];
Expand Down Expand Up @@ -9641,6 +9659,7 @@ function addContextMenuListener(elem, callback) {
elem.addEventListener('touchstart', touchStartHandler);
elem.addEventListener('touchmove', touchMoveHandler);
elem.addEventListener('touchend', touchEndHandler);
window.addEventListener('touchstart', globalTouchStartHandler);
} else {
elem.addEventListener('contextmenu', contextMenuHandler);
}
Expand All @@ -9650,6 +9669,7 @@ function addContextMenuListener(elem, callback) {
elem.removeEventListener('touchstart', touchStartHandler);
elem.removeEventListener('touchmove', touchMoveHandler);
elem.removeEventListener('touchend', touchEndHandler);
window.removeEventListener('touchstart', globalTouchStartHandler);
} else {
elem.removeEventListener('contextmenu', contextMenuHandler);
}
Expand Down Expand Up @@ -14773,10 +14793,10 @@ class Annotation extends Marker {
this._marker.addEventListener("click", this._onMouseClickedExternalMarker = () => {
this.plugin.fire("markerClicked", this);
});
this._onContextMenuExtenalMarker = () => {
this._onContextMenuExternalMarker = () => {
this.plugin.fire("contextmenu", this);
};
this._onContextMenuExtenalMarkerRemover = addContextMenuListener(this._markerHTML, this._onContextMenuExtenalMarker);
this._onContextMenuExternalMarkerRemover = addContextMenuListener(this._marker, this._onContextMenuExternalMarker);
this._marker.addEventListener("mouseenter", this._onMouseEnterExternalMarker = () => {
this.plugin.fire("markerMouseEnter", this);
});
Expand Down Expand Up @@ -15147,7 +15167,7 @@ class Annotation extends Marker {
this._marker = null;
} else {
this._marker.removeEventListener("click", this._onMouseClickedExternalMarker);
this._onContextMenuExtenalMarkerRemover();
this._onContextMenuExternalMarkerRemover();
this._marker.removeEventListener("mouseenter", this._onMouseEnterExternalMarker);
this._marker.removeEventListener("mouseleave", this._onMouseLeaveExternalMarker);
this._marker = null;
Expand Down Expand Up @@ -19392,6 +19412,8 @@ function getExtension (gl, name) {
return extension;
}

const vec3_0 = math.vec3([0,0,0]);

/**
* @private
*/
Expand Down Expand Up @@ -20070,9 +20092,11 @@ const Renderer$1 = function (scene, options) {
// Transparent color fill

if (normalFillTransparentBinLen > 0) {
const eye = frameCtx.pickOrigin || scene.camera.eye;
const byDist = normalFillTransparentBin.map(d => ({ drawable: d, distSq: math.distVec3(d.origin || vec3_0, eye) }));
byDist.sort((a, b) => b.distSq - a.distSq);
for (i = 0; i < normalFillTransparentBinLen; i++) {
drawable = normalFillTransparentBin[i];
drawable.drawColorTransparent(frameCtx);
byDist[i].drawable.drawColorTransparent(frameCtx);
}
}

Expand Down Expand Up @@ -73107,6 +73131,10 @@ class DTXTrianglesColorRenderer {
const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
const baseIndex = dataTextureLayer.layerIndex * numSectionPlanes;
const renderFlags = model.renderFlags;
if (scene.crossSections) {
gl.uniform4fv(this._uSliceColor, scene.crossSections.sliceColor);
gl.uniform1f(this._uSliceThickness, scene.crossSections.sliceThickness);
}
for (let sectionPlaneIndex = 0; sectionPlaneIndex < numAllocatedSectionPlanes; sectionPlaneIndex++) {
const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex];
if (sectionPlaneUniforms) {
Expand Down Expand Up @@ -73244,6 +73272,11 @@ class DTXTrianglesColorRenderer {
this._uTexturePerPolygonIdPortionIds = "uTexturePerPolygonIdPortionIds";
this._uTexturePerObjectMatrix= "uTexturePerObjectMatrix";
this._uCameraEyeRtc = program.getLocation("uCameraEyeRtc");

if (scene.crossSections) {
this._uSliceColor = program.getLocation("sliceColor");
this._uSliceThickness = program.getLocation("sliceThickness");
}
}

_bindProgram(frameCtx) {
Expand Down Expand Up @@ -73560,11 +73593,14 @@ class DTXTrianglesColorRenderer {
src.push("uniform vec3 sectionPlanePos" + i + ";");
src.push("uniform vec3 sectionPlaneDir" + i + ";");
}
src.push("uniform float sliceThickness;");
src.push("uniform vec4 sliceColor;");
}
src.push("in vec4 vColor;");
src.push("out vec4 outColor;");
src.push("void main(void) {");

src.push(" vec4 newColor;");
src.push(" newColor = vColor;");
if (clipping) {
src.push(" bool clippable = vFlags2 > 0u;");
src.push(" if (clippable) {");
Expand All @@ -73574,9 +73610,12 @@ class DTXTrianglesColorRenderer {
src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
src.push("}");
}
src.push(" if (dist > 0.0) { ");
src.push(" if (dist > sliceThickness) { ");
src.push(" discard;");
src.push(" }");
src.push(" if (dist > 0.0) { ");
src.push(" newColor = sliceColor;");
src.push(" }");
src.push("}");
}

Expand All @@ -73594,9 +73633,9 @@ class DTXTrianglesColorRenderer {
src.push(" float blendFactor = uSAOParams[3];");
src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");
src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");
src.push(" outColor = vec4(vColor.rgb * ambient, 1.0);");
src.push(" outColor = vec4(newColor.rgb * ambient, 1.0);");
} else {
src.push(" outColor = vColor;");
src.push(" outColor = newColor;");
}

src.push("}");
Expand Down Expand Up @@ -74038,10 +74077,14 @@ class DTXTrianglesSilhouetteRenderer {
src.push("uniform vec3 sectionPlanePos" + i + ";");
src.push("uniform vec3 sectionPlaneDir" + i + ";");
}
src.push("uniform float sliceThickness;");
src.push("uniform vec4 sliceColor;");
}
src.push("uniform vec4 color;");
src.push("out vec4 outColor;");
src.push("void main(void) {");
src.push(" vec4 newColor;");
src.push(" newColor = color;");
if (clipping) {
src.push(" bool clippable = vFlags2 > 0u;");
src.push(" if (clippable) {");
Expand All @@ -74051,15 +74094,18 @@ class DTXTrianglesSilhouetteRenderer {
src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
src.push("}");
}
src.push(" if (dist > 0.0) { ");
src.push(" if (dist > sliceThickness) { ");
src.push(" discard;");
src.push(" }");
src.push(" if (dist > 0.0) { ");
src.push(" newColor = sliceColor;");
src.push(" }");
src.push("}");
}
if (scene.logarithmicDepthBufferEnabled) {
src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
}
src.push(" outColor = color;");
src.push(" outColor = newColor;");
src.push("}");
return src;
}
Expand Down Expand Up @@ -74458,10 +74504,14 @@ class DTXTrianglesEdgesRenderer {
src.push("uniform vec3 sectionPlanePos" + i + ";");
src.push("uniform vec3 sectionPlaneDir" + i + ";");
}
src.push("uniform float sliceThickness;");
src.push("uniform vec4 sliceColor;");
}
src.push("in vec4 vColor;");
src.push("out vec4 outColor;");
src.push("void main(void) {");
src.push(" vec4 newColor;");
src.push(" newColor = vColor;");
if (clipping) {
src.push(" bool clippable = vFlags2 > 0u;");
src.push(" if (clippable) {");
Expand All @@ -74471,13 +74521,18 @@ class DTXTrianglesEdgesRenderer {
src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
src.push("}");
}
src.push(" if (dist > 0.0) { discard; }");
src.push(" if (dist > sliceThickness) { ");
src.push(" discard;");
src.push(" }");
src.push(" if (dist > 0.0) { ");
src.push(" newColor = sliceColor;");
src.push(" }");
src.push("}");
}
if (scene.logarithmicDepthBufferEnabled) {
src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
}
src.push(" outColor = vColor;");
src.push(" outColor = newColor;");
src.push("}");
return src;
}
Expand Down Expand Up @@ -74867,10 +74922,14 @@ class DTXTrianglesEdgesColorRenderer {
src.push("uniform vec3 sectionPlanePos" + i + ";");
src.push("uniform vec3 sectionPlaneDir" + i + ";");
}
src.push("uniform float sliceThickness;");
src.push("uniform vec4 sliceColor;");
}
src.push("in vec4 vColor;");
src.push("out vec4 outColor;");
src.push("void main(void) {");
src.push(" vec4 newColor;");
src.push(" newColor = vColor;");
if (clipping) {
src.push(" bool clippable = vFlags2 > 0u;");
src.push(" if (clippable) {");
Expand All @@ -74880,13 +74939,18 @@ class DTXTrianglesEdgesColorRenderer {
src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
src.push("}");
}
src.push(" if (dist > 0.0) { discard; }");
src.push(" if (dist > sliceThickness) { ");
src.push(" discard;");
src.push(" }");
src.push(" if (dist > 0.0) { ");
src.push(" newColor = sliceColor;");
src.push(" }");
src.push("}");
}
if (scene.logarithmicDepthBufferEnabled) {
src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
}
src.push(" outColor = vColor;");
src.push(" outColor = newColor;");
src.push("}");
return src;
}
Expand Down Expand Up @@ -97733,7 +97797,7 @@ class MousePickHandler {

this._timeout = setTimeout(() => {

if (firstClickPickResult && firstClickPickResult.worldPos) {
if (firstClickPickResult) {

cameraControl.fire("picked", firstClickPickResult, true);

Expand Down Expand Up @@ -101925,8 +101989,8 @@ class MetaScene {

for (let modelId in this.metaModels) {
const metaModel = this.metaModels[modelId];
for (let i = 0, len = metaModel.metaObjects.length; i < len; i++) {
const metaObject = metaModel.metaObjects[i];
for (let objectId in metaModel.metaObjects) {
const metaObject = metaModel.metaObjects[objectId];
metaObject.metaModels.push(metaModel);
}
}
Expand Down Expand Up @@ -140850,8 +140914,21 @@ class Zone extends Component {
}


const positions = [].concat(...pos);
const min = idx => Math.min(...pos.map(p => p[idx]));
const max = idx => Math.max(...pos.map(p => p[idx]));

const xmin = min(0);
const ymin = min(1);
const zmin = min(2);
const xmax = max(0);
const ymax = max(1);
const zmax = max(2);

this._center = math.vec3([ (xmin + xmax) / 2, (ymin + ymax) / 2, (zmin + zmax) / 2 ]);

const positions = [].concat(...pos.map(p => math.subVec3(p, this._center, p)));
this._zoneMesh = new Mesh(scene, {
origin: this._center,
edges: this._edges,
geometry: new ReadableGeometry(
scene,
Expand Down Expand Up @@ -140892,19 +140969,6 @@ class Zone extends Component {
}

this._metrics = null;


const min = idx => Math.min(...pos.map(p => p[idx]));
const max = idx => Math.max(...pos.map(p => p[idx]));

const xmin = min(0);
const ymin = min(1);
const zmin = min(2);
const xmax = max(0);
const ymax = max(1);
const zmax = max(2);

this._center = math.vec3([ (xmin + xmax) / 2, (ymin + ymax) / 2, (zmin + zmax) / 2 ]);
}

get baseArea() {
Expand Down
Loading

0 comments on commit 98913a0

Please sign in to comment.