Initial project import
This commit is contained in:
326
node_modules/three-stdlib/interactive/HTMLMesh.cjs
generated
vendored
Normal file
326
node_modules/three-stdlib/interactive/HTMLMesh.cjs
generated
vendored
Normal file
@@ -0,0 +1,326 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
const THREE = require("three");
|
||||
class HTMLMesh extends THREE.Mesh {
|
||||
constructor(dom) {
|
||||
const texture = new HTMLTexture(dom);
|
||||
const geometry = new THREE.PlaneGeometry(texture.image.width * 1e-3, texture.image.height * 1e-3);
|
||||
const material = new THREE.MeshBasicMaterial({ map: texture, toneMapped: false, transparent: true });
|
||||
super(geometry, material);
|
||||
function onEvent(event) {
|
||||
material.map.dispatchDOMEvent(event);
|
||||
}
|
||||
this.addEventListener("mousedown", onEvent);
|
||||
this.addEventListener("mousemove", onEvent);
|
||||
this.addEventListener("mouseup", onEvent);
|
||||
this.addEventListener("click", onEvent);
|
||||
this.dispose = function() {
|
||||
geometry.dispose();
|
||||
material.dispose();
|
||||
material.map.dispose();
|
||||
canvases.delete(dom);
|
||||
this.removeEventListener("mousedown", onEvent);
|
||||
this.removeEventListener("mousemove", onEvent);
|
||||
this.removeEventListener("mouseup", onEvent);
|
||||
this.removeEventListener("click", onEvent);
|
||||
};
|
||||
}
|
||||
}
|
||||
class HTMLTexture extends THREE.CanvasTexture {
|
||||
constructor(dom) {
|
||||
super(html2canvas(dom));
|
||||
this.dom = dom;
|
||||
this.anisotropy = 16;
|
||||
if ("colorSpace" in this)
|
||||
this.colorSpace = "srgb";
|
||||
else
|
||||
this.encoding = 3001;
|
||||
this.minFilter = THREE.LinearFilter;
|
||||
this.magFilter = THREE.LinearFilter;
|
||||
const observer = new MutationObserver(() => {
|
||||
if (!this.scheduleUpdate) {
|
||||
this.scheduleUpdate = setTimeout(() => this.update(), 16);
|
||||
}
|
||||
});
|
||||
const config = { attributes: true, childList: true, subtree: true, characterData: true };
|
||||
observer.observe(dom, config);
|
||||
this.observer = observer;
|
||||
}
|
||||
dispatchDOMEvent(event) {
|
||||
if (event.data) {
|
||||
htmlevent(this.dom, event.type, event.data.x, event.data.y);
|
||||
}
|
||||
}
|
||||
update() {
|
||||
this.image = html2canvas(this.dom);
|
||||
this.needsUpdate = true;
|
||||
this.scheduleUpdate = null;
|
||||
}
|
||||
dispose() {
|
||||
if (this.observer) {
|
||||
this.observer.disconnect();
|
||||
}
|
||||
this.scheduleUpdate = clearTimeout(this.scheduleUpdate);
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
const canvases = /* @__PURE__ */ new WeakMap();
|
||||
function html2canvas(element) {
|
||||
const range = document.createRange();
|
||||
const color = new THREE.Color();
|
||||
function Clipper(context2) {
|
||||
const clips = [];
|
||||
let isClipping = false;
|
||||
function doClip() {
|
||||
if (isClipping) {
|
||||
isClipping = false;
|
||||
context2.restore();
|
||||
}
|
||||
if (clips.length === 0)
|
||||
return;
|
||||
let minX = -Infinity, minY = -Infinity;
|
||||
let maxX = Infinity, maxY = Infinity;
|
||||
for (let i = 0; i < clips.length; i++) {
|
||||
const clip = clips[i];
|
||||
minX = Math.max(minX, clip.x);
|
||||
minY = Math.max(minY, clip.y);
|
||||
maxX = Math.min(maxX, clip.x + clip.width);
|
||||
maxY = Math.min(maxY, clip.y + clip.height);
|
||||
}
|
||||
context2.save();
|
||||
context2.beginPath();
|
||||
context2.rect(minX, minY, maxX - minX, maxY - minY);
|
||||
context2.clip();
|
||||
isClipping = true;
|
||||
}
|
||||
return {
|
||||
add: function(clip) {
|
||||
clips.push(clip);
|
||||
doClip();
|
||||
},
|
||||
remove: function() {
|
||||
clips.pop();
|
||||
doClip();
|
||||
}
|
||||
};
|
||||
}
|
||||
function drawText(style, x, y, string) {
|
||||
if (string !== "") {
|
||||
if (style.textTransform === "uppercase") {
|
||||
string = string.toUpperCase();
|
||||
}
|
||||
context.font = style.fontWeight + " " + style.fontSize + " " + style.fontFamily;
|
||||
context.textBaseline = "top";
|
||||
context.fillStyle = style.color;
|
||||
context.fillText(string, x, y + parseFloat(style.fontSize) * 0.1);
|
||||
}
|
||||
}
|
||||
function buildRectPath(x, y, w, h, r) {
|
||||
if (w < 2 * r)
|
||||
r = w / 2;
|
||||
if (h < 2 * r)
|
||||
r = h / 2;
|
||||
context.beginPath();
|
||||
context.moveTo(x + r, y);
|
||||
context.arcTo(x + w, y, x + w, y + h, r);
|
||||
context.arcTo(x + w, y + h, x, y + h, r);
|
||||
context.arcTo(x, y + h, x, y, r);
|
||||
context.arcTo(x, y, x + w, y, r);
|
||||
context.closePath();
|
||||
}
|
||||
function drawBorder(style, which, x, y, width, height) {
|
||||
const borderWidth = style[which + "Width"];
|
||||
const borderStyle = style[which + "Style"];
|
||||
const borderColor = style[which + "Color"];
|
||||
if (borderWidth !== "0px" && borderStyle !== "none" && borderColor !== "transparent" && borderColor !== "rgba(0, 0, 0, 0)") {
|
||||
context.strokeStyle = borderColor;
|
||||
context.lineWidth = parseFloat(borderWidth);
|
||||
context.beginPath();
|
||||
context.moveTo(x, y);
|
||||
context.lineTo(x + width, y + height);
|
||||
context.stroke();
|
||||
}
|
||||
}
|
||||
function drawElement(element2, style) {
|
||||
let x = 0, y = 0, width = 0, height = 0;
|
||||
if (element2.nodeType === Node.TEXT_NODE) {
|
||||
range.selectNode(element2);
|
||||
const rect = range.getBoundingClientRect();
|
||||
x = rect.left - offset.left - 0.5;
|
||||
y = rect.top - offset.top - 0.5;
|
||||
width = rect.width;
|
||||
height = rect.height;
|
||||
drawText(style, x, y, element2.nodeValue.trim());
|
||||
} else if (element2.nodeType === Node.COMMENT_NODE) {
|
||||
return;
|
||||
} else if (element2 instanceof HTMLCanvasElement) {
|
||||
if (element2.style.display === "none")
|
||||
return;
|
||||
context.save();
|
||||
const dpr = window.devicePixelRatio;
|
||||
context.scale(1 / dpr, 1 / dpr);
|
||||
context.drawImage(element2, 0, 0);
|
||||
context.restore();
|
||||
} else {
|
||||
if (element2.style.display === "none")
|
||||
return;
|
||||
const rect = element2.getBoundingClientRect();
|
||||
x = rect.left - offset.left - 0.5;
|
||||
y = rect.top - offset.top - 0.5;
|
||||
width = rect.width;
|
||||
height = rect.height;
|
||||
style = window.getComputedStyle(element2);
|
||||
buildRectPath(x, y, width, height, parseFloat(style.borderRadius));
|
||||
const backgroundColor = style.backgroundColor;
|
||||
if (backgroundColor !== "transparent" && backgroundColor !== "rgba(0, 0, 0, 0)") {
|
||||
context.fillStyle = backgroundColor;
|
||||
context.fill();
|
||||
}
|
||||
const borders = ["borderTop", "borderLeft", "borderBottom", "borderRight"];
|
||||
let match = true;
|
||||
let prevBorder = null;
|
||||
for (const border of borders) {
|
||||
if (prevBorder !== null) {
|
||||
match = style[border + "Width"] === style[prevBorder + "Width"] && style[border + "Color"] === style[prevBorder + "Color"] && style[border + "Style"] === style[prevBorder + "Style"];
|
||||
}
|
||||
if (match === false)
|
||||
break;
|
||||
prevBorder = border;
|
||||
}
|
||||
if (match === true) {
|
||||
const width2 = parseFloat(style.borderTopWidth);
|
||||
if (style.borderTopWidth !== "0px" && style.borderTopStyle !== "none" && style.borderTopColor !== "transparent" && style.borderTopColor !== "rgba(0, 0, 0, 0)") {
|
||||
context.strokeStyle = style.borderTopColor;
|
||||
context.lineWidth = width2;
|
||||
context.stroke();
|
||||
}
|
||||
} else {
|
||||
drawBorder(style, "borderTop", x, y, width, 0);
|
||||
drawBorder(style, "borderLeft", x, y, 0, height);
|
||||
drawBorder(style, "borderBottom", x, y + height, width, 0);
|
||||
drawBorder(style, "borderRight", x + width, y, 0, height);
|
||||
}
|
||||
if (element2 instanceof HTMLInputElement) {
|
||||
let accentColor = style.accentColor;
|
||||
if (accentColor === void 0 || accentColor === "auto")
|
||||
accentColor = style.color;
|
||||
color.set(accentColor);
|
||||
const luminance = Math.sqrt(0.299 * color.r ** 2 + 0.587 * color.g ** 2 + 0.114 * color.b ** 2);
|
||||
const accentTextColor = luminance < 0.5 ? "white" : "#111111";
|
||||
if (element2.type === "radio") {
|
||||
buildRectPath(x, y, width, height, height);
|
||||
context.fillStyle = "white";
|
||||
context.strokeStyle = accentColor;
|
||||
context.lineWidth = 1;
|
||||
context.fill();
|
||||
context.stroke();
|
||||
if (element2.checked) {
|
||||
buildRectPath(x + 2, y + 2, width - 4, height - 4, height);
|
||||
context.fillStyle = accentColor;
|
||||
context.strokeStyle = accentTextColor;
|
||||
context.lineWidth = 2;
|
||||
context.fill();
|
||||
context.stroke();
|
||||
}
|
||||
}
|
||||
if (element2.type === "checkbox") {
|
||||
buildRectPath(x, y, width, height, 2);
|
||||
context.fillStyle = element2.checked ? accentColor : "white";
|
||||
context.strokeStyle = element2.checked ? accentTextColor : accentColor;
|
||||
context.lineWidth = 1;
|
||||
context.stroke();
|
||||
context.fill();
|
||||
if (element2.checked) {
|
||||
const currentTextAlign = context.textAlign;
|
||||
context.textAlign = "center";
|
||||
const properties = {
|
||||
color: accentTextColor,
|
||||
fontFamily: style.fontFamily,
|
||||
fontSize: height + "px",
|
||||
fontWeight: "bold"
|
||||
};
|
||||
drawText(properties, x + width / 2, y, "✔");
|
||||
context.textAlign = currentTextAlign;
|
||||
}
|
||||
}
|
||||
if (element2.type === "range") {
|
||||
const [min, max, value] = ["min", "max", "value"].map((property) => parseFloat(element2[property]));
|
||||
const position = (value - min) / (max - min) * (width - height);
|
||||
buildRectPath(x, y + height / 4, width, height / 2, height / 4);
|
||||
context.fillStyle = accentTextColor;
|
||||
context.strokeStyle = accentColor;
|
||||
context.lineWidth = 1;
|
||||
context.fill();
|
||||
context.stroke();
|
||||
buildRectPath(x, y + height / 4, position + height / 2, height / 2, height / 4);
|
||||
context.fillStyle = accentColor;
|
||||
context.fill();
|
||||
buildRectPath(x + position, y, height, height, height / 2);
|
||||
context.fillStyle = accentColor;
|
||||
context.fill();
|
||||
}
|
||||
if (element2.type === "color" || element2.type === "text" || element2.type === "number") {
|
||||
clipper.add({ x, y, width, height });
|
||||
drawText(style, x + parseInt(style.paddingLeft), y + parseInt(style.paddingTop), element2.value);
|
||||
clipper.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
const isClipping = style.overflow === "auto" || style.overflow === "hidden";
|
||||
if (isClipping)
|
||||
clipper.add({ x, y, width, height });
|
||||
for (let i = 0; i < element2.childNodes.length; i++) {
|
||||
drawElement(element2.childNodes[i], style);
|
||||
}
|
||||
if (isClipping)
|
||||
clipper.remove();
|
||||
}
|
||||
const offset = element.getBoundingClientRect();
|
||||
let canvas = canvases.get(element);
|
||||
if (canvas === void 0) {
|
||||
canvas = document.createElement("canvas");
|
||||
canvas.width = offset.width;
|
||||
canvas.height = offset.height;
|
||||
canvases.set(element, canvas);
|
||||
}
|
||||
const context = canvas.getContext(
|
||||
"2d"
|
||||
/*, { alpha: false }*/
|
||||
);
|
||||
const clipper = new Clipper(context);
|
||||
drawElement(element);
|
||||
return canvas;
|
||||
}
|
||||
function htmlevent(element, event, x, y) {
|
||||
const mouseEventInit = {
|
||||
clientX: x * element.offsetWidth + element.offsetLeft,
|
||||
clientY: y * element.offsetHeight + element.offsetTop,
|
||||
view: element.ownerDocument.defaultView
|
||||
};
|
||||
window.dispatchEvent(new MouseEvent(event, mouseEventInit));
|
||||
const rect = element.getBoundingClientRect();
|
||||
x = x * rect.width + rect.left;
|
||||
y = y * rect.height + rect.top;
|
||||
function traverse(element2) {
|
||||
if (element2.nodeType !== Node.TEXT_NODE && element2.nodeType !== Node.COMMENT_NODE) {
|
||||
const rect2 = element2.getBoundingClientRect();
|
||||
if (x > rect2.left && x < rect2.right && y > rect2.top && y < rect2.bottom) {
|
||||
element2.dispatchEvent(new MouseEvent(event, mouseEventInit));
|
||||
if (element2 instanceof HTMLInputElement && element2.type === "range" && (event === "mousedown" || event === "click")) {
|
||||
const [min, max] = ["min", "max"].map((property) => parseFloat(element2[property]));
|
||||
const width = rect2.width;
|
||||
const offsetX = x - rect2.x;
|
||||
const proportion = offsetX / width;
|
||||
element2.value = min + (max - min) * proportion;
|
||||
element2.dispatchEvent(new InputEvent("input", { bubbles: true }));
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < element2.childNodes.length; i++) {
|
||||
traverse(element2.childNodes[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
traverse(element);
|
||||
}
|
||||
exports.HTMLMesh = HTMLMesh;
|
||||
//# sourceMappingURL=HTMLMesh.cjs.map
|
||||
1
node_modules/three-stdlib/interactive/HTMLMesh.cjs.map
generated
vendored
Normal file
1
node_modules/three-stdlib/interactive/HTMLMesh.cjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
6
node_modules/three-stdlib/interactive/HTMLMesh.d.ts
generated
vendored
Normal file
6
node_modules/three-stdlib/interactive/HTMLMesh.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { Mesh } from 'three'
|
||||
|
||||
export class HTMLMesh extends Mesh {
|
||||
constructor(dom: HTMLElement)
|
||||
dispose(): void
|
||||
}
|
||||
326
node_modules/three-stdlib/interactive/HTMLMesh.js
generated
vendored
Normal file
326
node_modules/three-stdlib/interactive/HTMLMesh.js
generated
vendored
Normal file
@@ -0,0 +1,326 @@
|
||||
import { Mesh, PlaneGeometry, MeshBasicMaterial, CanvasTexture, LinearFilter, Color } from "three";
|
||||
class HTMLMesh extends Mesh {
|
||||
constructor(dom) {
|
||||
const texture = new HTMLTexture(dom);
|
||||
const geometry = new PlaneGeometry(texture.image.width * 1e-3, texture.image.height * 1e-3);
|
||||
const material = new MeshBasicMaterial({ map: texture, toneMapped: false, transparent: true });
|
||||
super(geometry, material);
|
||||
function onEvent(event) {
|
||||
material.map.dispatchDOMEvent(event);
|
||||
}
|
||||
this.addEventListener("mousedown", onEvent);
|
||||
this.addEventListener("mousemove", onEvent);
|
||||
this.addEventListener("mouseup", onEvent);
|
||||
this.addEventListener("click", onEvent);
|
||||
this.dispose = function() {
|
||||
geometry.dispose();
|
||||
material.dispose();
|
||||
material.map.dispose();
|
||||
canvases.delete(dom);
|
||||
this.removeEventListener("mousedown", onEvent);
|
||||
this.removeEventListener("mousemove", onEvent);
|
||||
this.removeEventListener("mouseup", onEvent);
|
||||
this.removeEventListener("click", onEvent);
|
||||
};
|
||||
}
|
||||
}
|
||||
class HTMLTexture extends CanvasTexture {
|
||||
constructor(dom) {
|
||||
super(html2canvas(dom));
|
||||
this.dom = dom;
|
||||
this.anisotropy = 16;
|
||||
if ("colorSpace" in this)
|
||||
this.colorSpace = "srgb";
|
||||
else
|
||||
this.encoding = 3001;
|
||||
this.minFilter = LinearFilter;
|
||||
this.magFilter = LinearFilter;
|
||||
const observer = new MutationObserver(() => {
|
||||
if (!this.scheduleUpdate) {
|
||||
this.scheduleUpdate = setTimeout(() => this.update(), 16);
|
||||
}
|
||||
});
|
||||
const config = { attributes: true, childList: true, subtree: true, characterData: true };
|
||||
observer.observe(dom, config);
|
||||
this.observer = observer;
|
||||
}
|
||||
dispatchDOMEvent(event) {
|
||||
if (event.data) {
|
||||
htmlevent(this.dom, event.type, event.data.x, event.data.y);
|
||||
}
|
||||
}
|
||||
update() {
|
||||
this.image = html2canvas(this.dom);
|
||||
this.needsUpdate = true;
|
||||
this.scheduleUpdate = null;
|
||||
}
|
||||
dispose() {
|
||||
if (this.observer) {
|
||||
this.observer.disconnect();
|
||||
}
|
||||
this.scheduleUpdate = clearTimeout(this.scheduleUpdate);
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
const canvases = /* @__PURE__ */ new WeakMap();
|
||||
function html2canvas(element) {
|
||||
const range = document.createRange();
|
||||
const color = new Color();
|
||||
function Clipper(context2) {
|
||||
const clips = [];
|
||||
let isClipping = false;
|
||||
function doClip() {
|
||||
if (isClipping) {
|
||||
isClipping = false;
|
||||
context2.restore();
|
||||
}
|
||||
if (clips.length === 0)
|
||||
return;
|
||||
let minX = -Infinity, minY = -Infinity;
|
||||
let maxX = Infinity, maxY = Infinity;
|
||||
for (let i = 0; i < clips.length; i++) {
|
||||
const clip = clips[i];
|
||||
minX = Math.max(minX, clip.x);
|
||||
minY = Math.max(minY, clip.y);
|
||||
maxX = Math.min(maxX, clip.x + clip.width);
|
||||
maxY = Math.min(maxY, clip.y + clip.height);
|
||||
}
|
||||
context2.save();
|
||||
context2.beginPath();
|
||||
context2.rect(minX, minY, maxX - minX, maxY - minY);
|
||||
context2.clip();
|
||||
isClipping = true;
|
||||
}
|
||||
return {
|
||||
add: function(clip) {
|
||||
clips.push(clip);
|
||||
doClip();
|
||||
},
|
||||
remove: function() {
|
||||
clips.pop();
|
||||
doClip();
|
||||
}
|
||||
};
|
||||
}
|
||||
function drawText(style, x, y, string) {
|
||||
if (string !== "") {
|
||||
if (style.textTransform === "uppercase") {
|
||||
string = string.toUpperCase();
|
||||
}
|
||||
context.font = style.fontWeight + " " + style.fontSize + " " + style.fontFamily;
|
||||
context.textBaseline = "top";
|
||||
context.fillStyle = style.color;
|
||||
context.fillText(string, x, y + parseFloat(style.fontSize) * 0.1);
|
||||
}
|
||||
}
|
||||
function buildRectPath(x, y, w, h, r) {
|
||||
if (w < 2 * r)
|
||||
r = w / 2;
|
||||
if (h < 2 * r)
|
||||
r = h / 2;
|
||||
context.beginPath();
|
||||
context.moveTo(x + r, y);
|
||||
context.arcTo(x + w, y, x + w, y + h, r);
|
||||
context.arcTo(x + w, y + h, x, y + h, r);
|
||||
context.arcTo(x, y + h, x, y, r);
|
||||
context.arcTo(x, y, x + w, y, r);
|
||||
context.closePath();
|
||||
}
|
||||
function drawBorder(style, which, x, y, width, height) {
|
||||
const borderWidth = style[which + "Width"];
|
||||
const borderStyle = style[which + "Style"];
|
||||
const borderColor = style[which + "Color"];
|
||||
if (borderWidth !== "0px" && borderStyle !== "none" && borderColor !== "transparent" && borderColor !== "rgba(0, 0, 0, 0)") {
|
||||
context.strokeStyle = borderColor;
|
||||
context.lineWidth = parseFloat(borderWidth);
|
||||
context.beginPath();
|
||||
context.moveTo(x, y);
|
||||
context.lineTo(x + width, y + height);
|
||||
context.stroke();
|
||||
}
|
||||
}
|
||||
function drawElement(element2, style) {
|
||||
let x = 0, y = 0, width = 0, height = 0;
|
||||
if (element2.nodeType === Node.TEXT_NODE) {
|
||||
range.selectNode(element2);
|
||||
const rect = range.getBoundingClientRect();
|
||||
x = rect.left - offset.left - 0.5;
|
||||
y = rect.top - offset.top - 0.5;
|
||||
width = rect.width;
|
||||
height = rect.height;
|
||||
drawText(style, x, y, element2.nodeValue.trim());
|
||||
} else if (element2.nodeType === Node.COMMENT_NODE) {
|
||||
return;
|
||||
} else if (element2 instanceof HTMLCanvasElement) {
|
||||
if (element2.style.display === "none")
|
||||
return;
|
||||
context.save();
|
||||
const dpr = window.devicePixelRatio;
|
||||
context.scale(1 / dpr, 1 / dpr);
|
||||
context.drawImage(element2, 0, 0);
|
||||
context.restore();
|
||||
} else {
|
||||
if (element2.style.display === "none")
|
||||
return;
|
||||
const rect = element2.getBoundingClientRect();
|
||||
x = rect.left - offset.left - 0.5;
|
||||
y = rect.top - offset.top - 0.5;
|
||||
width = rect.width;
|
||||
height = rect.height;
|
||||
style = window.getComputedStyle(element2);
|
||||
buildRectPath(x, y, width, height, parseFloat(style.borderRadius));
|
||||
const backgroundColor = style.backgroundColor;
|
||||
if (backgroundColor !== "transparent" && backgroundColor !== "rgba(0, 0, 0, 0)") {
|
||||
context.fillStyle = backgroundColor;
|
||||
context.fill();
|
||||
}
|
||||
const borders = ["borderTop", "borderLeft", "borderBottom", "borderRight"];
|
||||
let match = true;
|
||||
let prevBorder = null;
|
||||
for (const border of borders) {
|
||||
if (prevBorder !== null) {
|
||||
match = style[border + "Width"] === style[prevBorder + "Width"] && style[border + "Color"] === style[prevBorder + "Color"] && style[border + "Style"] === style[prevBorder + "Style"];
|
||||
}
|
||||
if (match === false)
|
||||
break;
|
||||
prevBorder = border;
|
||||
}
|
||||
if (match === true) {
|
||||
const width2 = parseFloat(style.borderTopWidth);
|
||||
if (style.borderTopWidth !== "0px" && style.borderTopStyle !== "none" && style.borderTopColor !== "transparent" && style.borderTopColor !== "rgba(0, 0, 0, 0)") {
|
||||
context.strokeStyle = style.borderTopColor;
|
||||
context.lineWidth = width2;
|
||||
context.stroke();
|
||||
}
|
||||
} else {
|
||||
drawBorder(style, "borderTop", x, y, width, 0);
|
||||
drawBorder(style, "borderLeft", x, y, 0, height);
|
||||
drawBorder(style, "borderBottom", x, y + height, width, 0);
|
||||
drawBorder(style, "borderRight", x + width, y, 0, height);
|
||||
}
|
||||
if (element2 instanceof HTMLInputElement) {
|
||||
let accentColor = style.accentColor;
|
||||
if (accentColor === void 0 || accentColor === "auto")
|
||||
accentColor = style.color;
|
||||
color.set(accentColor);
|
||||
const luminance = Math.sqrt(0.299 * color.r ** 2 + 0.587 * color.g ** 2 + 0.114 * color.b ** 2);
|
||||
const accentTextColor = luminance < 0.5 ? "white" : "#111111";
|
||||
if (element2.type === "radio") {
|
||||
buildRectPath(x, y, width, height, height);
|
||||
context.fillStyle = "white";
|
||||
context.strokeStyle = accentColor;
|
||||
context.lineWidth = 1;
|
||||
context.fill();
|
||||
context.stroke();
|
||||
if (element2.checked) {
|
||||
buildRectPath(x + 2, y + 2, width - 4, height - 4, height);
|
||||
context.fillStyle = accentColor;
|
||||
context.strokeStyle = accentTextColor;
|
||||
context.lineWidth = 2;
|
||||
context.fill();
|
||||
context.stroke();
|
||||
}
|
||||
}
|
||||
if (element2.type === "checkbox") {
|
||||
buildRectPath(x, y, width, height, 2);
|
||||
context.fillStyle = element2.checked ? accentColor : "white";
|
||||
context.strokeStyle = element2.checked ? accentTextColor : accentColor;
|
||||
context.lineWidth = 1;
|
||||
context.stroke();
|
||||
context.fill();
|
||||
if (element2.checked) {
|
||||
const currentTextAlign = context.textAlign;
|
||||
context.textAlign = "center";
|
||||
const properties = {
|
||||
color: accentTextColor,
|
||||
fontFamily: style.fontFamily,
|
||||
fontSize: height + "px",
|
||||
fontWeight: "bold"
|
||||
};
|
||||
drawText(properties, x + width / 2, y, "✔");
|
||||
context.textAlign = currentTextAlign;
|
||||
}
|
||||
}
|
||||
if (element2.type === "range") {
|
||||
const [min, max, value] = ["min", "max", "value"].map((property) => parseFloat(element2[property]));
|
||||
const position = (value - min) / (max - min) * (width - height);
|
||||
buildRectPath(x, y + height / 4, width, height / 2, height / 4);
|
||||
context.fillStyle = accentTextColor;
|
||||
context.strokeStyle = accentColor;
|
||||
context.lineWidth = 1;
|
||||
context.fill();
|
||||
context.stroke();
|
||||
buildRectPath(x, y + height / 4, position + height / 2, height / 2, height / 4);
|
||||
context.fillStyle = accentColor;
|
||||
context.fill();
|
||||
buildRectPath(x + position, y, height, height, height / 2);
|
||||
context.fillStyle = accentColor;
|
||||
context.fill();
|
||||
}
|
||||
if (element2.type === "color" || element2.type === "text" || element2.type === "number") {
|
||||
clipper.add({ x, y, width, height });
|
||||
drawText(style, x + parseInt(style.paddingLeft), y + parseInt(style.paddingTop), element2.value);
|
||||
clipper.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
const isClipping = style.overflow === "auto" || style.overflow === "hidden";
|
||||
if (isClipping)
|
||||
clipper.add({ x, y, width, height });
|
||||
for (let i = 0; i < element2.childNodes.length; i++) {
|
||||
drawElement(element2.childNodes[i], style);
|
||||
}
|
||||
if (isClipping)
|
||||
clipper.remove();
|
||||
}
|
||||
const offset = element.getBoundingClientRect();
|
||||
let canvas = canvases.get(element);
|
||||
if (canvas === void 0) {
|
||||
canvas = document.createElement("canvas");
|
||||
canvas.width = offset.width;
|
||||
canvas.height = offset.height;
|
||||
canvases.set(element, canvas);
|
||||
}
|
||||
const context = canvas.getContext(
|
||||
"2d"
|
||||
/*, { alpha: false }*/
|
||||
);
|
||||
const clipper = new Clipper(context);
|
||||
drawElement(element);
|
||||
return canvas;
|
||||
}
|
||||
function htmlevent(element, event, x, y) {
|
||||
const mouseEventInit = {
|
||||
clientX: x * element.offsetWidth + element.offsetLeft,
|
||||
clientY: y * element.offsetHeight + element.offsetTop,
|
||||
view: element.ownerDocument.defaultView
|
||||
};
|
||||
window.dispatchEvent(new MouseEvent(event, mouseEventInit));
|
||||
const rect = element.getBoundingClientRect();
|
||||
x = x * rect.width + rect.left;
|
||||
y = y * rect.height + rect.top;
|
||||
function traverse(element2) {
|
||||
if (element2.nodeType !== Node.TEXT_NODE && element2.nodeType !== Node.COMMENT_NODE) {
|
||||
const rect2 = element2.getBoundingClientRect();
|
||||
if (x > rect2.left && x < rect2.right && y > rect2.top && y < rect2.bottom) {
|
||||
element2.dispatchEvent(new MouseEvent(event, mouseEventInit));
|
||||
if (element2 instanceof HTMLInputElement && element2.type === "range" && (event === "mousedown" || event === "click")) {
|
||||
const [min, max] = ["min", "max"].map((property) => parseFloat(element2[property]));
|
||||
const width = rect2.width;
|
||||
const offsetX = x - rect2.x;
|
||||
const proportion = offsetX / width;
|
||||
element2.value = min + (max - min) * proportion;
|
||||
element2.dispatchEvent(new InputEvent("input", { bubbles: true }));
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < element2.childNodes.length; i++) {
|
||||
traverse(element2.childNodes[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
traverse(element);
|
||||
}
|
||||
export {
|
||||
HTMLMesh
|
||||
};
|
||||
//# sourceMappingURL=HTMLMesh.js.map
|
||||
1
node_modules/three-stdlib/interactive/HTMLMesh.js.map
generated
vendored
Normal file
1
node_modules/three-stdlib/interactive/HTMLMesh.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
69
node_modules/three-stdlib/interactive/InteractiveGroup.cjs
generated
vendored
Normal file
69
node_modules/three-stdlib/interactive/InteractiveGroup.cjs
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
const THREE = require("three");
|
||||
const _pointer = /* @__PURE__ */ new THREE.Vector2();
|
||||
const _event = { type: "", data: _pointer };
|
||||
class InteractiveGroup extends THREE.Group {
|
||||
constructor(renderer, camera) {
|
||||
super();
|
||||
const scope = this;
|
||||
const raycaster = new THREE.Raycaster();
|
||||
const tempMatrix = new THREE.Matrix4();
|
||||
const element = renderer.domElement;
|
||||
function onPointerEvent(event) {
|
||||
event.stopPropagation();
|
||||
_pointer.x = event.clientX / element.clientWidth * 2 - 1;
|
||||
_pointer.y = -(event.clientY / element.clientHeight) * 2 + 1;
|
||||
raycaster.setFromCamera(_pointer, camera);
|
||||
const intersects = raycaster.intersectObjects(scope.children, false);
|
||||
if (intersects.length > 0) {
|
||||
const intersection = intersects[0];
|
||||
const object = intersection.object;
|
||||
const uv = intersection.uv;
|
||||
_event.type = event.type;
|
||||
_event.data.set(uv.x, 1 - uv.y);
|
||||
object.dispatchEvent(_event);
|
||||
}
|
||||
}
|
||||
element.addEventListener("pointerdown", onPointerEvent);
|
||||
element.addEventListener("pointerup", onPointerEvent);
|
||||
element.addEventListener("pointermove", onPointerEvent);
|
||||
element.addEventListener("mousedown", onPointerEvent);
|
||||
element.addEventListener("mouseup", onPointerEvent);
|
||||
element.addEventListener("mousemove", onPointerEvent);
|
||||
element.addEventListener("click", onPointerEvent);
|
||||
const events = {
|
||||
move: "mousemove",
|
||||
select: "click",
|
||||
selectstart: "mousedown",
|
||||
selectend: "mouseup"
|
||||
};
|
||||
function onXRControllerEvent(event) {
|
||||
const controller = event.target;
|
||||
tempMatrix.identity().extractRotation(controller.matrixWorld);
|
||||
raycaster.ray.origin.setFromMatrixPosition(controller.matrixWorld);
|
||||
raycaster.ray.direction.set(0, 0, -1).applyMatrix4(tempMatrix);
|
||||
const intersections = raycaster.intersectObjects(scope.children, false);
|
||||
if (intersections.length > 0) {
|
||||
const intersection = intersections[0];
|
||||
const object = intersection.object;
|
||||
const uv = intersection.uv;
|
||||
_event.type = events[event.type];
|
||||
_event.data.set(uv.x, 1 - uv.y);
|
||||
object.dispatchEvent(_event);
|
||||
}
|
||||
}
|
||||
const controller1 = renderer.xr.getController(0);
|
||||
controller1.addEventListener("move", onXRControllerEvent);
|
||||
controller1.addEventListener("select", onXRControllerEvent);
|
||||
controller1.addEventListener("selectstart", onXRControllerEvent);
|
||||
controller1.addEventListener("selectend", onXRControllerEvent);
|
||||
const controller2 = renderer.xr.getController(1);
|
||||
controller2.addEventListener("move", onXRControllerEvent);
|
||||
controller2.addEventListener("select", onXRControllerEvent);
|
||||
controller2.addEventListener("selectstart", onXRControllerEvent);
|
||||
controller2.addEventListener("selectend", onXRControllerEvent);
|
||||
}
|
||||
}
|
||||
exports.InteractiveGroup = InteractiveGroup;
|
||||
//# sourceMappingURL=InteractiveGroup.cjs.map
|
||||
1
node_modules/three-stdlib/interactive/InteractiveGroup.cjs.map
generated
vendored
Normal file
1
node_modules/three-stdlib/interactive/InteractiveGroup.cjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"InteractiveGroup.cjs","sources":["../../src/interactive/InteractiveGroup.js"],"sourcesContent":["import { Group, Matrix4, Raycaster, Vector2 } from 'three'\n\nconst _pointer = /* @__PURE__ */ new Vector2()\nconst _event = { type: '', data: _pointer }\n\nclass InteractiveGroup extends Group {\n constructor(renderer, camera) {\n super()\n\n const scope = this\n\n const raycaster = new Raycaster()\n const tempMatrix = new Matrix4()\n\n // Pointer Events\n\n const element = renderer.domElement\n\n function onPointerEvent(event) {\n event.stopPropagation()\n\n _pointer.x = (event.clientX / element.clientWidth) * 2 - 1\n _pointer.y = -(event.clientY / element.clientHeight) * 2 + 1\n\n raycaster.setFromCamera(_pointer, camera)\n\n const intersects = raycaster.intersectObjects(scope.children, false)\n\n if (intersects.length > 0) {\n const intersection = intersects[0]\n\n const object = intersection.object\n const uv = intersection.uv\n\n _event.type = event.type\n _event.data.set(uv.x, 1 - uv.y)\n\n object.dispatchEvent(_event)\n }\n }\n\n element.addEventListener('pointerdown', onPointerEvent)\n element.addEventListener('pointerup', onPointerEvent)\n element.addEventListener('pointermove', onPointerEvent)\n element.addEventListener('mousedown', onPointerEvent)\n element.addEventListener('mouseup', onPointerEvent)\n element.addEventListener('mousemove', onPointerEvent)\n element.addEventListener('click', onPointerEvent)\n\n // WebXR Controller Events\n // TODO: Dispatch pointerevents too\n\n const events = {\n move: 'mousemove',\n select: 'click',\n selectstart: 'mousedown',\n selectend: 'mouseup',\n }\n\n function onXRControllerEvent(event) {\n const controller = event.target\n\n tempMatrix.identity().extractRotation(controller.matrixWorld)\n\n raycaster.ray.origin.setFromMatrixPosition(controller.matrixWorld)\n raycaster.ray.direction.set(0, 0, -1).applyMatrix4(tempMatrix)\n\n const intersections = raycaster.intersectObjects(scope.children, false)\n\n if (intersections.length > 0) {\n const intersection = intersections[0]\n\n const object = intersection.object\n const uv = intersection.uv\n\n _event.type = events[event.type]\n _event.data.set(uv.x, 1 - uv.y)\n\n object.dispatchEvent(_event)\n }\n }\n\n const controller1 = renderer.xr.getController(0)\n controller1.addEventListener('move', onXRControllerEvent)\n controller1.addEventListener('select', onXRControllerEvent)\n controller1.addEventListener('selectstart', onXRControllerEvent)\n controller1.addEventListener('selectend', onXRControllerEvent)\n\n const controller2 = renderer.xr.getController(1)\n controller2.addEventListener('move', onXRControllerEvent)\n controller2.addEventListener('select', onXRControllerEvent)\n controller2.addEventListener('selectstart', onXRControllerEvent)\n controller2.addEventListener('selectend', onXRControllerEvent)\n }\n}\n\nexport { InteractiveGroup }\n"],"names":["Vector2","Group","Raycaster","Matrix4"],"mappings":";;;AAEA,MAAM,WAA2B,oBAAIA,MAAAA,QAAS;AAC9C,MAAM,SAAS,EAAE,MAAM,IAAI,MAAM,SAAU;AAE3C,MAAM,yBAAyBC,MAAAA,MAAM;AAAA,EACnC,YAAY,UAAU,QAAQ;AAC5B,UAAO;AAEP,UAAM,QAAQ;AAEd,UAAM,YAAY,IAAIC,gBAAW;AACjC,UAAM,aAAa,IAAIC,cAAS;AAIhC,UAAM,UAAU,SAAS;AAEzB,aAAS,eAAe,OAAO;AAC7B,YAAM,gBAAiB;AAEvB,eAAS,IAAK,MAAM,UAAU,QAAQ,cAAe,IAAI;AACzD,eAAS,IAAI,EAAE,MAAM,UAAU,QAAQ,gBAAgB,IAAI;AAE3D,gBAAU,cAAc,UAAU,MAAM;AAExC,YAAM,aAAa,UAAU,iBAAiB,MAAM,UAAU,KAAK;AAEnE,UAAI,WAAW,SAAS,GAAG;AACzB,cAAM,eAAe,WAAW,CAAC;AAEjC,cAAM,SAAS,aAAa;AAC5B,cAAM,KAAK,aAAa;AAExB,eAAO,OAAO,MAAM;AACpB,eAAO,KAAK,IAAI,GAAG,GAAG,IAAI,GAAG,CAAC;AAE9B,eAAO,cAAc,MAAM;AAAA,MAC5B;AAAA,IACF;AAED,YAAQ,iBAAiB,eAAe,cAAc;AACtD,YAAQ,iBAAiB,aAAa,cAAc;AACpD,YAAQ,iBAAiB,eAAe,cAAc;AACtD,YAAQ,iBAAiB,aAAa,cAAc;AACpD,YAAQ,iBAAiB,WAAW,cAAc;AAClD,YAAQ,iBAAiB,aAAa,cAAc;AACpD,YAAQ,iBAAiB,SAAS,cAAc;AAKhD,UAAM,SAAS;AAAA,MACb,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,WAAW;AAAA,IACZ;AAED,aAAS,oBAAoB,OAAO;AAClC,YAAM,aAAa,MAAM;AAEzB,iBAAW,SAAU,EAAC,gBAAgB,WAAW,WAAW;AAE5D,gBAAU,IAAI,OAAO,sBAAsB,WAAW,WAAW;AACjE,gBAAU,IAAI,UAAU,IAAI,GAAG,GAAG,EAAE,EAAE,aAAa,UAAU;AAE7D,YAAM,gBAAgB,UAAU,iBAAiB,MAAM,UAAU,KAAK;AAEtE,UAAI,cAAc,SAAS,GAAG;AAC5B,cAAM,eAAe,cAAc,CAAC;AAEpC,cAAM,SAAS,aAAa;AAC5B,cAAM,KAAK,aAAa;AAExB,eAAO,OAAO,OAAO,MAAM,IAAI;AAC/B,eAAO,KAAK,IAAI,GAAG,GAAG,IAAI,GAAG,CAAC;AAE9B,eAAO,cAAc,MAAM;AAAA,MAC5B;AAAA,IACF;AAED,UAAM,cAAc,SAAS,GAAG,cAAc,CAAC;AAC/C,gBAAY,iBAAiB,QAAQ,mBAAmB;AACxD,gBAAY,iBAAiB,UAAU,mBAAmB;AAC1D,gBAAY,iBAAiB,eAAe,mBAAmB;AAC/D,gBAAY,iBAAiB,aAAa,mBAAmB;AAE7D,UAAM,cAAc,SAAS,GAAG,cAAc,CAAC;AAC/C,gBAAY,iBAAiB,QAAQ,mBAAmB;AACxD,gBAAY,iBAAiB,UAAU,mBAAmB;AAC1D,gBAAY,iBAAiB,eAAe,mBAAmB;AAC/D,gBAAY,iBAAiB,aAAa,mBAAmB;AAAA,EAC9D;AACH;;"}
|
||||
5
node_modules/three-stdlib/interactive/InteractiveGroup.d.ts
generated
vendored
Normal file
5
node_modules/three-stdlib/interactive/InteractiveGroup.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { WebGLRenderer, Camera, Group } from 'three'
|
||||
|
||||
export class InteractiveGroup extends Group {
|
||||
constructor(renderer: WebGLRenderer, camera: Camera)
|
||||
}
|
||||
69
node_modules/three-stdlib/interactive/InteractiveGroup.js
generated
vendored
Normal file
69
node_modules/three-stdlib/interactive/InteractiveGroup.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
import { Group, Raycaster, Matrix4, Vector2 } from "three";
|
||||
const _pointer = /* @__PURE__ */ new Vector2();
|
||||
const _event = { type: "", data: _pointer };
|
||||
class InteractiveGroup extends Group {
|
||||
constructor(renderer, camera) {
|
||||
super();
|
||||
const scope = this;
|
||||
const raycaster = new Raycaster();
|
||||
const tempMatrix = new Matrix4();
|
||||
const element = renderer.domElement;
|
||||
function onPointerEvent(event) {
|
||||
event.stopPropagation();
|
||||
_pointer.x = event.clientX / element.clientWidth * 2 - 1;
|
||||
_pointer.y = -(event.clientY / element.clientHeight) * 2 + 1;
|
||||
raycaster.setFromCamera(_pointer, camera);
|
||||
const intersects = raycaster.intersectObjects(scope.children, false);
|
||||
if (intersects.length > 0) {
|
||||
const intersection = intersects[0];
|
||||
const object = intersection.object;
|
||||
const uv = intersection.uv;
|
||||
_event.type = event.type;
|
||||
_event.data.set(uv.x, 1 - uv.y);
|
||||
object.dispatchEvent(_event);
|
||||
}
|
||||
}
|
||||
element.addEventListener("pointerdown", onPointerEvent);
|
||||
element.addEventListener("pointerup", onPointerEvent);
|
||||
element.addEventListener("pointermove", onPointerEvent);
|
||||
element.addEventListener("mousedown", onPointerEvent);
|
||||
element.addEventListener("mouseup", onPointerEvent);
|
||||
element.addEventListener("mousemove", onPointerEvent);
|
||||
element.addEventListener("click", onPointerEvent);
|
||||
const events = {
|
||||
move: "mousemove",
|
||||
select: "click",
|
||||
selectstart: "mousedown",
|
||||
selectend: "mouseup"
|
||||
};
|
||||
function onXRControllerEvent(event) {
|
||||
const controller = event.target;
|
||||
tempMatrix.identity().extractRotation(controller.matrixWorld);
|
||||
raycaster.ray.origin.setFromMatrixPosition(controller.matrixWorld);
|
||||
raycaster.ray.direction.set(0, 0, -1).applyMatrix4(tempMatrix);
|
||||
const intersections = raycaster.intersectObjects(scope.children, false);
|
||||
if (intersections.length > 0) {
|
||||
const intersection = intersections[0];
|
||||
const object = intersection.object;
|
||||
const uv = intersection.uv;
|
||||
_event.type = events[event.type];
|
||||
_event.data.set(uv.x, 1 - uv.y);
|
||||
object.dispatchEvent(_event);
|
||||
}
|
||||
}
|
||||
const controller1 = renderer.xr.getController(0);
|
||||
controller1.addEventListener("move", onXRControllerEvent);
|
||||
controller1.addEventListener("select", onXRControllerEvent);
|
||||
controller1.addEventListener("selectstart", onXRControllerEvent);
|
||||
controller1.addEventListener("selectend", onXRControllerEvent);
|
||||
const controller2 = renderer.xr.getController(1);
|
||||
controller2.addEventListener("move", onXRControllerEvent);
|
||||
controller2.addEventListener("select", onXRControllerEvent);
|
||||
controller2.addEventListener("selectstart", onXRControllerEvent);
|
||||
controller2.addEventListener("selectend", onXRControllerEvent);
|
||||
}
|
||||
}
|
||||
export {
|
||||
InteractiveGroup
|
||||
};
|
||||
//# sourceMappingURL=InteractiveGroup.js.map
|
||||
1
node_modules/three-stdlib/interactive/InteractiveGroup.js.map
generated
vendored
Normal file
1
node_modules/three-stdlib/interactive/InteractiveGroup.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"InteractiveGroup.js","sources":["../../src/interactive/InteractiveGroup.js"],"sourcesContent":["import { Group, Matrix4, Raycaster, Vector2 } from 'three'\n\nconst _pointer = /* @__PURE__ */ new Vector2()\nconst _event = { type: '', data: _pointer }\n\nclass InteractiveGroup extends Group {\n constructor(renderer, camera) {\n super()\n\n const scope = this\n\n const raycaster = new Raycaster()\n const tempMatrix = new Matrix4()\n\n // Pointer Events\n\n const element = renderer.domElement\n\n function onPointerEvent(event) {\n event.stopPropagation()\n\n _pointer.x = (event.clientX / element.clientWidth) * 2 - 1\n _pointer.y = -(event.clientY / element.clientHeight) * 2 + 1\n\n raycaster.setFromCamera(_pointer, camera)\n\n const intersects = raycaster.intersectObjects(scope.children, false)\n\n if (intersects.length > 0) {\n const intersection = intersects[0]\n\n const object = intersection.object\n const uv = intersection.uv\n\n _event.type = event.type\n _event.data.set(uv.x, 1 - uv.y)\n\n object.dispatchEvent(_event)\n }\n }\n\n element.addEventListener('pointerdown', onPointerEvent)\n element.addEventListener('pointerup', onPointerEvent)\n element.addEventListener('pointermove', onPointerEvent)\n element.addEventListener('mousedown', onPointerEvent)\n element.addEventListener('mouseup', onPointerEvent)\n element.addEventListener('mousemove', onPointerEvent)\n element.addEventListener('click', onPointerEvent)\n\n // WebXR Controller Events\n // TODO: Dispatch pointerevents too\n\n const events = {\n move: 'mousemove',\n select: 'click',\n selectstart: 'mousedown',\n selectend: 'mouseup',\n }\n\n function onXRControllerEvent(event) {\n const controller = event.target\n\n tempMatrix.identity().extractRotation(controller.matrixWorld)\n\n raycaster.ray.origin.setFromMatrixPosition(controller.matrixWorld)\n raycaster.ray.direction.set(0, 0, -1).applyMatrix4(tempMatrix)\n\n const intersections = raycaster.intersectObjects(scope.children, false)\n\n if (intersections.length > 0) {\n const intersection = intersections[0]\n\n const object = intersection.object\n const uv = intersection.uv\n\n _event.type = events[event.type]\n _event.data.set(uv.x, 1 - uv.y)\n\n object.dispatchEvent(_event)\n }\n }\n\n const controller1 = renderer.xr.getController(0)\n controller1.addEventListener('move', onXRControllerEvent)\n controller1.addEventListener('select', onXRControllerEvent)\n controller1.addEventListener('selectstart', onXRControllerEvent)\n controller1.addEventListener('selectend', onXRControllerEvent)\n\n const controller2 = renderer.xr.getController(1)\n controller2.addEventListener('move', onXRControllerEvent)\n controller2.addEventListener('select', onXRControllerEvent)\n controller2.addEventListener('selectstart', onXRControllerEvent)\n controller2.addEventListener('selectend', onXRControllerEvent)\n }\n}\n\nexport { InteractiveGroup }\n"],"names":[],"mappings":";AAEA,MAAM,WAA2B,oBAAI,QAAS;AAC9C,MAAM,SAAS,EAAE,MAAM,IAAI,MAAM,SAAU;AAE3C,MAAM,yBAAyB,MAAM;AAAA,EACnC,YAAY,UAAU,QAAQ;AAC5B,UAAO;AAEP,UAAM,QAAQ;AAEd,UAAM,YAAY,IAAI,UAAW;AACjC,UAAM,aAAa,IAAI,QAAS;AAIhC,UAAM,UAAU,SAAS;AAEzB,aAAS,eAAe,OAAO;AAC7B,YAAM,gBAAiB;AAEvB,eAAS,IAAK,MAAM,UAAU,QAAQ,cAAe,IAAI;AACzD,eAAS,IAAI,EAAE,MAAM,UAAU,QAAQ,gBAAgB,IAAI;AAE3D,gBAAU,cAAc,UAAU,MAAM;AAExC,YAAM,aAAa,UAAU,iBAAiB,MAAM,UAAU,KAAK;AAEnE,UAAI,WAAW,SAAS,GAAG;AACzB,cAAM,eAAe,WAAW,CAAC;AAEjC,cAAM,SAAS,aAAa;AAC5B,cAAM,KAAK,aAAa;AAExB,eAAO,OAAO,MAAM;AACpB,eAAO,KAAK,IAAI,GAAG,GAAG,IAAI,GAAG,CAAC;AAE9B,eAAO,cAAc,MAAM;AAAA,MAC5B;AAAA,IACF;AAED,YAAQ,iBAAiB,eAAe,cAAc;AACtD,YAAQ,iBAAiB,aAAa,cAAc;AACpD,YAAQ,iBAAiB,eAAe,cAAc;AACtD,YAAQ,iBAAiB,aAAa,cAAc;AACpD,YAAQ,iBAAiB,WAAW,cAAc;AAClD,YAAQ,iBAAiB,aAAa,cAAc;AACpD,YAAQ,iBAAiB,SAAS,cAAc;AAKhD,UAAM,SAAS;AAAA,MACb,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,WAAW;AAAA,IACZ;AAED,aAAS,oBAAoB,OAAO;AAClC,YAAM,aAAa,MAAM;AAEzB,iBAAW,SAAU,EAAC,gBAAgB,WAAW,WAAW;AAE5D,gBAAU,IAAI,OAAO,sBAAsB,WAAW,WAAW;AACjE,gBAAU,IAAI,UAAU,IAAI,GAAG,GAAG,EAAE,EAAE,aAAa,UAAU;AAE7D,YAAM,gBAAgB,UAAU,iBAAiB,MAAM,UAAU,KAAK;AAEtE,UAAI,cAAc,SAAS,GAAG;AAC5B,cAAM,eAAe,cAAc,CAAC;AAEpC,cAAM,SAAS,aAAa;AAC5B,cAAM,KAAK,aAAa;AAExB,eAAO,OAAO,OAAO,MAAM,IAAI;AAC/B,eAAO,KAAK,IAAI,GAAG,GAAG,IAAI,GAAG,CAAC;AAE9B,eAAO,cAAc,MAAM;AAAA,MAC5B;AAAA,IACF;AAED,UAAM,cAAc,SAAS,GAAG,cAAc,CAAC;AAC/C,gBAAY,iBAAiB,QAAQ,mBAAmB;AACxD,gBAAY,iBAAiB,UAAU,mBAAmB;AAC1D,gBAAY,iBAAiB,eAAe,mBAAmB;AAC/D,gBAAY,iBAAiB,aAAa,mBAAmB;AAE7D,UAAM,cAAc,SAAS,GAAG,cAAc,CAAC;AAC/C,gBAAY,iBAAiB,QAAQ,mBAAmB;AACxD,gBAAY,iBAAiB,UAAU,mBAAmB;AAC1D,gBAAY,iBAAiB,eAAe,mBAAmB;AAC/D,gBAAY,iBAAiB,aAAa,mBAAmB;AAAA,EAC9D;AACH;"}
|
||||
135
node_modules/three-stdlib/interactive/SelectionBox.cjs
generated
vendored
Normal file
135
node_modules/three-stdlib/interactive/SelectionBox.cjs
generated
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
const THREE = require("three");
|
||||
const frustum = /* @__PURE__ */ new THREE.Frustum();
|
||||
const center = /* @__PURE__ */ new THREE.Vector3();
|
||||
const tmpPoint = /* @__PURE__ */ new THREE.Vector3();
|
||||
const vecNear = /* @__PURE__ */ new THREE.Vector3();
|
||||
const vecTopLeft = /* @__PURE__ */ new THREE.Vector3();
|
||||
const vecTopRight = /* @__PURE__ */ new THREE.Vector3();
|
||||
const vecDownRight = /* @__PURE__ */ new THREE.Vector3();
|
||||
const vecDownLeft = /* @__PURE__ */ new THREE.Vector3();
|
||||
const vecFarTopLeft = /* @__PURE__ */ new THREE.Vector3();
|
||||
const vecFarTopRight = /* @__PURE__ */ new THREE.Vector3();
|
||||
const vecFarDownRight = /* @__PURE__ */ new THREE.Vector3();
|
||||
const vecFarDownLeft = /* @__PURE__ */ new THREE.Vector3();
|
||||
const vectemp1 = /* @__PURE__ */ new THREE.Vector3();
|
||||
const vectemp2 = /* @__PURE__ */ new THREE.Vector3();
|
||||
const vectemp3 = /* @__PURE__ */ new THREE.Vector3();
|
||||
class SelectionBox {
|
||||
constructor(camera, scene, deep) {
|
||||
this.camera = camera;
|
||||
this.scene = scene;
|
||||
this.startPoint = new THREE.Vector3();
|
||||
this.endPoint = new THREE.Vector3();
|
||||
this.collection = [];
|
||||
this.deep = deep || Number.MAX_VALUE;
|
||||
}
|
||||
select(startPoint, endPoint) {
|
||||
this.startPoint = startPoint || this.startPoint;
|
||||
this.endPoint = endPoint || this.endPoint;
|
||||
this.collection = [];
|
||||
this.updateFrustum(this.startPoint, this.endPoint);
|
||||
this.searchChildInFrustum(frustum, this.scene);
|
||||
return this.collection;
|
||||
}
|
||||
updateFrustum(startPoint, endPoint) {
|
||||
startPoint = startPoint || this.startPoint;
|
||||
endPoint = endPoint || this.endPoint;
|
||||
if (startPoint.x === endPoint.x) {
|
||||
endPoint.x += Number.EPSILON;
|
||||
}
|
||||
if (startPoint.y === endPoint.y) {
|
||||
endPoint.y += Number.EPSILON;
|
||||
}
|
||||
this.camera.updateProjectionMatrix();
|
||||
this.camera.updateMatrixWorld();
|
||||
if (this.camera.isPerspectiveCamera) {
|
||||
tmpPoint.copy(startPoint);
|
||||
tmpPoint.x = Math.min(startPoint.x, endPoint.x);
|
||||
tmpPoint.y = Math.max(startPoint.y, endPoint.y);
|
||||
endPoint.x = Math.max(startPoint.x, endPoint.x);
|
||||
endPoint.y = Math.min(startPoint.y, endPoint.y);
|
||||
vecNear.setFromMatrixPosition(this.camera.matrixWorld);
|
||||
vecTopLeft.copy(tmpPoint);
|
||||
vecTopRight.set(endPoint.x, tmpPoint.y, 0);
|
||||
vecDownRight.copy(endPoint);
|
||||
vecDownLeft.set(tmpPoint.x, endPoint.y, 0);
|
||||
vecTopLeft.unproject(this.camera);
|
||||
vecTopRight.unproject(this.camera);
|
||||
vecDownRight.unproject(this.camera);
|
||||
vecDownLeft.unproject(this.camera);
|
||||
vectemp1.copy(vecTopLeft).sub(vecNear);
|
||||
vectemp2.copy(vecTopRight).sub(vecNear);
|
||||
vectemp3.copy(vecDownRight).sub(vecNear);
|
||||
vectemp1.normalize();
|
||||
vectemp2.normalize();
|
||||
vectemp3.normalize();
|
||||
vectemp1.multiplyScalar(this.deep);
|
||||
vectemp2.multiplyScalar(this.deep);
|
||||
vectemp3.multiplyScalar(this.deep);
|
||||
vectemp1.add(vecNear);
|
||||
vectemp2.add(vecNear);
|
||||
vectemp3.add(vecNear);
|
||||
var planes = frustum.planes;
|
||||
planes[0].setFromCoplanarPoints(vecNear, vecTopLeft, vecTopRight);
|
||||
planes[1].setFromCoplanarPoints(vecNear, vecTopRight, vecDownRight);
|
||||
planes[2].setFromCoplanarPoints(vecDownRight, vecDownLeft, vecNear);
|
||||
planes[3].setFromCoplanarPoints(vecDownLeft, vecTopLeft, vecNear);
|
||||
planes[4].setFromCoplanarPoints(vecTopRight, vecDownRight, vecDownLeft);
|
||||
planes[5].setFromCoplanarPoints(vectemp3, vectemp2, vectemp1);
|
||||
planes[5].normal.multiplyScalar(-1);
|
||||
} else if (this.camera.isOrthographicCamera) {
|
||||
const left = Math.min(startPoint.x, endPoint.x);
|
||||
const top = Math.max(startPoint.y, endPoint.y);
|
||||
const right = Math.max(startPoint.x, endPoint.x);
|
||||
const down = Math.min(startPoint.y, endPoint.y);
|
||||
vecTopLeft.set(left, top, -1);
|
||||
vecTopRight.set(right, top, -1);
|
||||
vecDownRight.set(right, down, -1);
|
||||
vecDownLeft.set(left, down, -1);
|
||||
vecFarTopLeft.set(left, top, 1);
|
||||
vecFarTopRight.set(right, top, 1);
|
||||
vecFarDownRight.set(right, down, 1);
|
||||
vecFarDownLeft.set(left, down, 1);
|
||||
vecTopLeft.unproject(this.camera);
|
||||
vecTopRight.unproject(this.camera);
|
||||
vecDownRight.unproject(this.camera);
|
||||
vecDownLeft.unproject(this.camera);
|
||||
vecFarTopLeft.unproject(this.camera);
|
||||
vecFarTopRight.unproject(this.camera);
|
||||
vecFarDownRight.unproject(this.camera);
|
||||
vecFarDownLeft.unproject(this.camera);
|
||||
var planes = frustum.planes;
|
||||
planes[0].setFromCoplanarPoints(vecTopLeft, vecFarTopLeft, vecFarTopRight);
|
||||
planes[1].setFromCoplanarPoints(vecTopRight, vecFarTopRight, vecFarDownRight);
|
||||
planes[2].setFromCoplanarPoints(vecFarDownRight, vecFarDownLeft, vecDownLeft);
|
||||
planes[3].setFromCoplanarPoints(vecFarDownLeft, vecFarTopLeft, vecTopLeft);
|
||||
planes[4].setFromCoplanarPoints(vecTopRight, vecDownRight, vecDownLeft);
|
||||
planes[5].setFromCoplanarPoints(vecFarDownRight, vecFarTopRight, vecFarTopLeft);
|
||||
planes[5].normal.multiplyScalar(-1);
|
||||
} else {
|
||||
console.error("THREE.SelectionBox: Unsupported camera type.");
|
||||
}
|
||||
}
|
||||
searchChildInFrustum(frustum2, object) {
|
||||
if (object.isMesh || object.isLine || object.isPoints) {
|
||||
if (object.material !== void 0) {
|
||||
if (object.geometry.boundingSphere === null)
|
||||
object.geometry.computeBoundingSphere();
|
||||
center.copy(object.geometry.boundingSphere.center);
|
||||
center.applyMatrix4(object.matrixWorld);
|
||||
if (frustum2.containsPoint(center)) {
|
||||
this.collection.push(object);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (object.children.length > 0) {
|
||||
for (let x = 0; x < object.children.length; x++) {
|
||||
this.searchChildInFrustum(frustum2, object.children[x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.SelectionBox = SelectionBox;
|
||||
//# sourceMappingURL=SelectionBox.cjs.map
|
||||
1
node_modules/three-stdlib/interactive/SelectionBox.cjs.map
generated
vendored
Normal file
1
node_modules/three-stdlib/interactive/SelectionBox.cjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
15
node_modules/three-stdlib/interactive/SelectionBox.d.ts
generated
vendored
Normal file
15
node_modules/three-stdlib/interactive/SelectionBox.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Camera, Frustum, Mesh, Object3D, Scene, Vector3 } from 'three'
|
||||
|
||||
export class SelectionBox {
|
||||
constructor(camera: Camera, scene: Scene, deep?: number)
|
||||
camera: Camera
|
||||
collection: Mesh[]
|
||||
deep: number
|
||||
endPoint: Vector3
|
||||
scene: Scene
|
||||
startPoint: Vector3
|
||||
|
||||
select(startPoint?: Vector3, endPoint?: Vector3): Mesh[]
|
||||
updateFrustum(startPoint: Vector3, endPoint: Vector3): void
|
||||
searchChildInFrustum(frustum: Frustum, object: Object3D): void
|
||||
}
|
||||
135
node_modules/three-stdlib/interactive/SelectionBox.js
generated
vendored
Normal file
135
node_modules/three-stdlib/interactive/SelectionBox.js
generated
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
import { Vector3, Frustum } from "three";
|
||||
const frustum = /* @__PURE__ */ new Frustum();
|
||||
const center = /* @__PURE__ */ new Vector3();
|
||||
const tmpPoint = /* @__PURE__ */ new Vector3();
|
||||
const vecNear = /* @__PURE__ */ new Vector3();
|
||||
const vecTopLeft = /* @__PURE__ */ new Vector3();
|
||||
const vecTopRight = /* @__PURE__ */ new Vector3();
|
||||
const vecDownRight = /* @__PURE__ */ new Vector3();
|
||||
const vecDownLeft = /* @__PURE__ */ new Vector3();
|
||||
const vecFarTopLeft = /* @__PURE__ */ new Vector3();
|
||||
const vecFarTopRight = /* @__PURE__ */ new Vector3();
|
||||
const vecFarDownRight = /* @__PURE__ */ new Vector3();
|
||||
const vecFarDownLeft = /* @__PURE__ */ new Vector3();
|
||||
const vectemp1 = /* @__PURE__ */ new Vector3();
|
||||
const vectemp2 = /* @__PURE__ */ new Vector3();
|
||||
const vectemp3 = /* @__PURE__ */ new Vector3();
|
||||
class SelectionBox {
|
||||
constructor(camera, scene, deep) {
|
||||
this.camera = camera;
|
||||
this.scene = scene;
|
||||
this.startPoint = new Vector3();
|
||||
this.endPoint = new Vector3();
|
||||
this.collection = [];
|
||||
this.deep = deep || Number.MAX_VALUE;
|
||||
}
|
||||
select(startPoint, endPoint) {
|
||||
this.startPoint = startPoint || this.startPoint;
|
||||
this.endPoint = endPoint || this.endPoint;
|
||||
this.collection = [];
|
||||
this.updateFrustum(this.startPoint, this.endPoint);
|
||||
this.searchChildInFrustum(frustum, this.scene);
|
||||
return this.collection;
|
||||
}
|
||||
updateFrustum(startPoint, endPoint) {
|
||||
startPoint = startPoint || this.startPoint;
|
||||
endPoint = endPoint || this.endPoint;
|
||||
if (startPoint.x === endPoint.x) {
|
||||
endPoint.x += Number.EPSILON;
|
||||
}
|
||||
if (startPoint.y === endPoint.y) {
|
||||
endPoint.y += Number.EPSILON;
|
||||
}
|
||||
this.camera.updateProjectionMatrix();
|
||||
this.camera.updateMatrixWorld();
|
||||
if (this.camera.isPerspectiveCamera) {
|
||||
tmpPoint.copy(startPoint);
|
||||
tmpPoint.x = Math.min(startPoint.x, endPoint.x);
|
||||
tmpPoint.y = Math.max(startPoint.y, endPoint.y);
|
||||
endPoint.x = Math.max(startPoint.x, endPoint.x);
|
||||
endPoint.y = Math.min(startPoint.y, endPoint.y);
|
||||
vecNear.setFromMatrixPosition(this.camera.matrixWorld);
|
||||
vecTopLeft.copy(tmpPoint);
|
||||
vecTopRight.set(endPoint.x, tmpPoint.y, 0);
|
||||
vecDownRight.copy(endPoint);
|
||||
vecDownLeft.set(tmpPoint.x, endPoint.y, 0);
|
||||
vecTopLeft.unproject(this.camera);
|
||||
vecTopRight.unproject(this.camera);
|
||||
vecDownRight.unproject(this.camera);
|
||||
vecDownLeft.unproject(this.camera);
|
||||
vectemp1.copy(vecTopLeft).sub(vecNear);
|
||||
vectemp2.copy(vecTopRight).sub(vecNear);
|
||||
vectemp3.copy(vecDownRight).sub(vecNear);
|
||||
vectemp1.normalize();
|
||||
vectemp2.normalize();
|
||||
vectemp3.normalize();
|
||||
vectemp1.multiplyScalar(this.deep);
|
||||
vectemp2.multiplyScalar(this.deep);
|
||||
vectemp3.multiplyScalar(this.deep);
|
||||
vectemp1.add(vecNear);
|
||||
vectemp2.add(vecNear);
|
||||
vectemp3.add(vecNear);
|
||||
var planes = frustum.planes;
|
||||
planes[0].setFromCoplanarPoints(vecNear, vecTopLeft, vecTopRight);
|
||||
planes[1].setFromCoplanarPoints(vecNear, vecTopRight, vecDownRight);
|
||||
planes[2].setFromCoplanarPoints(vecDownRight, vecDownLeft, vecNear);
|
||||
planes[3].setFromCoplanarPoints(vecDownLeft, vecTopLeft, vecNear);
|
||||
planes[4].setFromCoplanarPoints(vecTopRight, vecDownRight, vecDownLeft);
|
||||
planes[5].setFromCoplanarPoints(vectemp3, vectemp2, vectemp1);
|
||||
planes[5].normal.multiplyScalar(-1);
|
||||
} else if (this.camera.isOrthographicCamera) {
|
||||
const left = Math.min(startPoint.x, endPoint.x);
|
||||
const top = Math.max(startPoint.y, endPoint.y);
|
||||
const right = Math.max(startPoint.x, endPoint.x);
|
||||
const down = Math.min(startPoint.y, endPoint.y);
|
||||
vecTopLeft.set(left, top, -1);
|
||||
vecTopRight.set(right, top, -1);
|
||||
vecDownRight.set(right, down, -1);
|
||||
vecDownLeft.set(left, down, -1);
|
||||
vecFarTopLeft.set(left, top, 1);
|
||||
vecFarTopRight.set(right, top, 1);
|
||||
vecFarDownRight.set(right, down, 1);
|
||||
vecFarDownLeft.set(left, down, 1);
|
||||
vecTopLeft.unproject(this.camera);
|
||||
vecTopRight.unproject(this.camera);
|
||||
vecDownRight.unproject(this.camera);
|
||||
vecDownLeft.unproject(this.camera);
|
||||
vecFarTopLeft.unproject(this.camera);
|
||||
vecFarTopRight.unproject(this.camera);
|
||||
vecFarDownRight.unproject(this.camera);
|
||||
vecFarDownLeft.unproject(this.camera);
|
||||
var planes = frustum.planes;
|
||||
planes[0].setFromCoplanarPoints(vecTopLeft, vecFarTopLeft, vecFarTopRight);
|
||||
planes[1].setFromCoplanarPoints(vecTopRight, vecFarTopRight, vecFarDownRight);
|
||||
planes[2].setFromCoplanarPoints(vecFarDownRight, vecFarDownLeft, vecDownLeft);
|
||||
planes[3].setFromCoplanarPoints(vecFarDownLeft, vecFarTopLeft, vecTopLeft);
|
||||
planes[4].setFromCoplanarPoints(vecTopRight, vecDownRight, vecDownLeft);
|
||||
planes[5].setFromCoplanarPoints(vecFarDownRight, vecFarTopRight, vecFarTopLeft);
|
||||
planes[5].normal.multiplyScalar(-1);
|
||||
} else {
|
||||
console.error("THREE.SelectionBox: Unsupported camera type.");
|
||||
}
|
||||
}
|
||||
searchChildInFrustum(frustum2, object) {
|
||||
if (object.isMesh || object.isLine || object.isPoints) {
|
||||
if (object.material !== void 0) {
|
||||
if (object.geometry.boundingSphere === null)
|
||||
object.geometry.computeBoundingSphere();
|
||||
center.copy(object.geometry.boundingSphere.center);
|
||||
center.applyMatrix4(object.matrixWorld);
|
||||
if (frustum2.containsPoint(center)) {
|
||||
this.collection.push(object);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (object.children.length > 0) {
|
||||
for (let x = 0; x < object.children.length; x++) {
|
||||
this.searchChildInFrustum(frustum2, object.children[x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
export {
|
||||
SelectionBox
|
||||
};
|
||||
//# sourceMappingURL=SelectionBox.js.map
|
||||
1
node_modules/three-stdlib/interactive/SelectionBox.js.map
generated
vendored
Normal file
1
node_modules/three-stdlib/interactive/SelectionBox.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
52
node_modules/three-stdlib/interactive/SelectionHelper.cjs
generated
vendored
Normal file
52
node_modules/three-stdlib/interactive/SelectionHelper.cjs
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
const THREE = require("three");
|
||||
class SelectionHelper {
|
||||
constructor(selectionBox, renderer, cssClassName) {
|
||||
this.element = document.createElement("div");
|
||||
this.element.classList.add(cssClassName);
|
||||
this.element.style.pointerEvents = "none";
|
||||
this.renderer = renderer;
|
||||
this.startPoint = new THREE.Vector2();
|
||||
this.pointTopLeft = new THREE.Vector2();
|
||||
this.pointBottomRight = new THREE.Vector2();
|
||||
this.isDown = false;
|
||||
this.renderer.domElement.addEventListener("pointerdown", (event) => {
|
||||
this.isDown = true;
|
||||
this.onSelectStart(event);
|
||||
});
|
||||
this.renderer.domElement.addEventListener("pointermove", (event) => {
|
||||
if (this.isDown) {
|
||||
this.onSelectMove(event);
|
||||
}
|
||||
});
|
||||
this.renderer.domElement.addEventListener("pointerup", (event) => {
|
||||
this.isDown = false;
|
||||
this.onSelectOver(event);
|
||||
});
|
||||
}
|
||||
onSelectStart(event) {
|
||||
this.renderer.domElement.parentElement.appendChild(this.element);
|
||||
this.element.style.left = `${event.clientX}px`;
|
||||
this.element.style.top = `${event.clientY}px`;
|
||||
this.element.style.width = "0px";
|
||||
this.element.style.height = "0px";
|
||||
this.startPoint.x = event.clientX;
|
||||
this.startPoint.y = event.clientY;
|
||||
}
|
||||
onSelectMove(event) {
|
||||
this.pointBottomRight.x = Math.max(this.startPoint.x, event.clientX);
|
||||
this.pointBottomRight.y = Math.max(this.startPoint.y, event.clientY);
|
||||
this.pointTopLeft.x = Math.min(this.startPoint.x, event.clientX);
|
||||
this.pointTopLeft.y = Math.min(this.startPoint.y, event.clientY);
|
||||
this.element.style.left = `${this.pointTopLeft.x}px`;
|
||||
this.element.style.top = `${this.pointTopLeft.y}px`;
|
||||
this.element.style.width = `${this.pointBottomRight.x - this.pointTopLeft.x}px`;
|
||||
this.element.style.height = `${this.pointBottomRight.y - this.pointTopLeft.y}px`;
|
||||
}
|
||||
onSelectOver() {
|
||||
this.element.parentElement.removeChild(this.element);
|
||||
}
|
||||
}
|
||||
exports.SelectionHelper = SelectionHelper;
|
||||
//# sourceMappingURL=SelectionHelper.cjs.map
|
||||
1
node_modules/three-stdlib/interactive/SelectionHelper.cjs.map
generated
vendored
Normal file
1
node_modules/three-stdlib/interactive/SelectionHelper.cjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"SelectionHelper.cjs","sources":["../../src/interactive/SelectionHelper.js"],"sourcesContent":["import { Vector2 } from 'three'\n\nclass SelectionHelper {\n constructor(selectionBox, renderer, cssClassName) {\n this.element = document.createElement('div')\n this.element.classList.add(cssClassName)\n this.element.style.pointerEvents = 'none'\n\n this.renderer = renderer\n\n this.startPoint = new Vector2()\n this.pointTopLeft = new Vector2()\n this.pointBottomRight = new Vector2()\n\n this.isDown = false\n\n this.renderer.domElement.addEventListener('pointerdown', (event) => {\n this.isDown = true\n this.onSelectStart(event)\n })\n\n this.renderer.domElement.addEventListener('pointermove', (event) => {\n if (this.isDown) {\n this.onSelectMove(event)\n }\n })\n\n this.renderer.domElement.addEventListener('pointerup', (event) => {\n this.isDown = false\n this.onSelectOver(event)\n })\n }\n\n onSelectStart(event) {\n this.renderer.domElement.parentElement.appendChild(this.element)\n\n this.element.style.left = `${event.clientX}px`\n this.element.style.top = `${event.clientY}px`\n this.element.style.width = '0px'\n this.element.style.height = '0px'\n\n this.startPoint.x = event.clientX\n this.startPoint.y = event.clientY\n }\n\n onSelectMove(event) {\n this.pointBottomRight.x = Math.max(this.startPoint.x, event.clientX)\n this.pointBottomRight.y = Math.max(this.startPoint.y, event.clientY)\n this.pointTopLeft.x = Math.min(this.startPoint.x, event.clientX)\n this.pointTopLeft.y = Math.min(this.startPoint.y, event.clientY)\n\n this.element.style.left = `${this.pointTopLeft.x}px`\n this.element.style.top = `${this.pointTopLeft.y}px`\n this.element.style.width = `${this.pointBottomRight.x - this.pointTopLeft.x}px`\n this.element.style.height = `${this.pointBottomRight.y - this.pointTopLeft.y}px`\n }\n\n onSelectOver() {\n this.element.parentElement.removeChild(this.element)\n }\n}\n\nexport { SelectionHelper }\n"],"names":["Vector2"],"mappings":";;;AAEA,MAAM,gBAAgB;AAAA,EACpB,YAAY,cAAc,UAAU,cAAc;AAChD,SAAK,UAAU,SAAS,cAAc,KAAK;AAC3C,SAAK,QAAQ,UAAU,IAAI,YAAY;AACvC,SAAK,QAAQ,MAAM,gBAAgB;AAEnC,SAAK,WAAW;AAEhB,SAAK,aAAa,IAAIA,cAAS;AAC/B,SAAK,eAAe,IAAIA,cAAS;AACjC,SAAK,mBAAmB,IAAIA,cAAS;AAErC,SAAK,SAAS;AAEd,SAAK,SAAS,WAAW,iBAAiB,eAAe,CAAC,UAAU;AAClE,WAAK,SAAS;AACd,WAAK,cAAc,KAAK;AAAA,IAC9B,CAAK;AAED,SAAK,SAAS,WAAW,iBAAiB,eAAe,CAAC,UAAU;AAClE,UAAI,KAAK,QAAQ;AACf,aAAK,aAAa,KAAK;AAAA,MACxB;AAAA,IACP,CAAK;AAED,SAAK,SAAS,WAAW,iBAAiB,aAAa,CAAC,UAAU;AAChE,WAAK,SAAS;AACd,WAAK,aAAa,KAAK;AAAA,IAC7B,CAAK;AAAA,EACF;AAAA,EAED,cAAc,OAAO;AACnB,SAAK,SAAS,WAAW,cAAc,YAAY,KAAK,OAAO;AAE/D,SAAK,QAAQ,MAAM,OAAO,GAAG,MAAM;AACnC,SAAK,QAAQ,MAAM,MAAM,GAAG,MAAM;AAClC,SAAK,QAAQ,MAAM,QAAQ;AAC3B,SAAK,QAAQ,MAAM,SAAS;AAE5B,SAAK,WAAW,IAAI,MAAM;AAC1B,SAAK,WAAW,IAAI,MAAM;AAAA,EAC3B;AAAA,EAED,aAAa,OAAO;AAClB,SAAK,iBAAiB,IAAI,KAAK,IAAI,KAAK,WAAW,GAAG,MAAM,OAAO;AACnE,SAAK,iBAAiB,IAAI,KAAK,IAAI,KAAK,WAAW,GAAG,MAAM,OAAO;AACnE,SAAK,aAAa,IAAI,KAAK,IAAI,KAAK,WAAW,GAAG,MAAM,OAAO;AAC/D,SAAK,aAAa,IAAI,KAAK,IAAI,KAAK,WAAW,GAAG,MAAM,OAAO;AAE/D,SAAK,QAAQ,MAAM,OAAO,GAAG,KAAK,aAAa;AAC/C,SAAK,QAAQ,MAAM,MAAM,GAAG,KAAK,aAAa;AAC9C,SAAK,QAAQ,MAAM,QAAQ,GAAG,KAAK,iBAAiB,IAAI,KAAK,aAAa;AAC1E,SAAK,QAAQ,MAAM,SAAS,GAAG,KAAK,iBAAiB,IAAI,KAAK,aAAa;AAAA,EAC5E;AAAA,EAED,eAAe;AACb,SAAK,QAAQ,cAAc,YAAY,KAAK,OAAO;AAAA,EACpD;AACH;;"}
|
||||
17
node_modules/three-stdlib/interactive/SelectionHelper.d.ts
generated
vendored
Normal file
17
node_modules/three-stdlib/interactive/SelectionHelper.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { WebGLRenderer, Vector2 } from 'three'
|
||||
|
||||
import { SelectionBox } from './SelectionBox'
|
||||
|
||||
export class SelectionHelper {
|
||||
constructor(selectionBox: SelectionBox, renderer: WebGLRenderer, cssClassName: string)
|
||||
element: HTMLElement
|
||||
isDown: boolean
|
||||
pointBottomRight: Vector2
|
||||
pointTopLeft: Vector2
|
||||
renderer: WebGLRenderer
|
||||
startPoint: Vector2
|
||||
|
||||
onSelectStart(event: Event): void
|
||||
onSelectMove(event: Event): void
|
||||
onSelectOver(event: Event): void
|
||||
}
|
||||
52
node_modules/three-stdlib/interactive/SelectionHelper.js
generated
vendored
Normal file
52
node_modules/three-stdlib/interactive/SelectionHelper.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
import { Vector2 } from "three";
|
||||
class SelectionHelper {
|
||||
constructor(selectionBox, renderer, cssClassName) {
|
||||
this.element = document.createElement("div");
|
||||
this.element.classList.add(cssClassName);
|
||||
this.element.style.pointerEvents = "none";
|
||||
this.renderer = renderer;
|
||||
this.startPoint = new Vector2();
|
||||
this.pointTopLeft = new Vector2();
|
||||
this.pointBottomRight = new Vector2();
|
||||
this.isDown = false;
|
||||
this.renderer.domElement.addEventListener("pointerdown", (event) => {
|
||||
this.isDown = true;
|
||||
this.onSelectStart(event);
|
||||
});
|
||||
this.renderer.domElement.addEventListener("pointermove", (event) => {
|
||||
if (this.isDown) {
|
||||
this.onSelectMove(event);
|
||||
}
|
||||
});
|
||||
this.renderer.domElement.addEventListener("pointerup", (event) => {
|
||||
this.isDown = false;
|
||||
this.onSelectOver(event);
|
||||
});
|
||||
}
|
||||
onSelectStart(event) {
|
||||
this.renderer.domElement.parentElement.appendChild(this.element);
|
||||
this.element.style.left = `${event.clientX}px`;
|
||||
this.element.style.top = `${event.clientY}px`;
|
||||
this.element.style.width = "0px";
|
||||
this.element.style.height = "0px";
|
||||
this.startPoint.x = event.clientX;
|
||||
this.startPoint.y = event.clientY;
|
||||
}
|
||||
onSelectMove(event) {
|
||||
this.pointBottomRight.x = Math.max(this.startPoint.x, event.clientX);
|
||||
this.pointBottomRight.y = Math.max(this.startPoint.y, event.clientY);
|
||||
this.pointTopLeft.x = Math.min(this.startPoint.x, event.clientX);
|
||||
this.pointTopLeft.y = Math.min(this.startPoint.y, event.clientY);
|
||||
this.element.style.left = `${this.pointTopLeft.x}px`;
|
||||
this.element.style.top = `${this.pointTopLeft.y}px`;
|
||||
this.element.style.width = `${this.pointBottomRight.x - this.pointTopLeft.x}px`;
|
||||
this.element.style.height = `${this.pointBottomRight.y - this.pointTopLeft.y}px`;
|
||||
}
|
||||
onSelectOver() {
|
||||
this.element.parentElement.removeChild(this.element);
|
||||
}
|
||||
}
|
||||
export {
|
||||
SelectionHelper
|
||||
};
|
||||
//# sourceMappingURL=SelectionHelper.js.map
|
||||
1
node_modules/three-stdlib/interactive/SelectionHelper.js.map
generated
vendored
Normal file
1
node_modules/three-stdlib/interactive/SelectionHelper.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"SelectionHelper.js","sources":["../../src/interactive/SelectionHelper.js"],"sourcesContent":["import { Vector2 } from 'three'\n\nclass SelectionHelper {\n constructor(selectionBox, renderer, cssClassName) {\n this.element = document.createElement('div')\n this.element.classList.add(cssClassName)\n this.element.style.pointerEvents = 'none'\n\n this.renderer = renderer\n\n this.startPoint = new Vector2()\n this.pointTopLeft = new Vector2()\n this.pointBottomRight = new Vector2()\n\n this.isDown = false\n\n this.renderer.domElement.addEventListener('pointerdown', (event) => {\n this.isDown = true\n this.onSelectStart(event)\n })\n\n this.renderer.domElement.addEventListener('pointermove', (event) => {\n if (this.isDown) {\n this.onSelectMove(event)\n }\n })\n\n this.renderer.domElement.addEventListener('pointerup', (event) => {\n this.isDown = false\n this.onSelectOver(event)\n })\n }\n\n onSelectStart(event) {\n this.renderer.domElement.parentElement.appendChild(this.element)\n\n this.element.style.left = `${event.clientX}px`\n this.element.style.top = `${event.clientY}px`\n this.element.style.width = '0px'\n this.element.style.height = '0px'\n\n this.startPoint.x = event.clientX\n this.startPoint.y = event.clientY\n }\n\n onSelectMove(event) {\n this.pointBottomRight.x = Math.max(this.startPoint.x, event.clientX)\n this.pointBottomRight.y = Math.max(this.startPoint.y, event.clientY)\n this.pointTopLeft.x = Math.min(this.startPoint.x, event.clientX)\n this.pointTopLeft.y = Math.min(this.startPoint.y, event.clientY)\n\n this.element.style.left = `${this.pointTopLeft.x}px`\n this.element.style.top = `${this.pointTopLeft.y}px`\n this.element.style.width = `${this.pointBottomRight.x - this.pointTopLeft.x}px`\n this.element.style.height = `${this.pointBottomRight.y - this.pointTopLeft.y}px`\n }\n\n onSelectOver() {\n this.element.parentElement.removeChild(this.element)\n }\n}\n\nexport { SelectionHelper }\n"],"names":[],"mappings":";AAEA,MAAM,gBAAgB;AAAA,EACpB,YAAY,cAAc,UAAU,cAAc;AAChD,SAAK,UAAU,SAAS,cAAc,KAAK;AAC3C,SAAK,QAAQ,UAAU,IAAI,YAAY;AACvC,SAAK,QAAQ,MAAM,gBAAgB;AAEnC,SAAK,WAAW;AAEhB,SAAK,aAAa,IAAI,QAAS;AAC/B,SAAK,eAAe,IAAI,QAAS;AACjC,SAAK,mBAAmB,IAAI,QAAS;AAErC,SAAK,SAAS;AAEd,SAAK,SAAS,WAAW,iBAAiB,eAAe,CAAC,UAAU;AAClE,WAAK,SAAS;AACd,WAAK,cAAc,KAAK;AAAA,IAC9B,CAAK;AAED,SAAK,SAAS,WAAW,iBAAiB,eAAe,CAAC,UAAU;AAClE,UAAI,KAAK,QAAQ;AACf,aAAK,aAAa,KAAK;AAAA,MACxB;AAAA,IACP,CAAK;AAED,SAAK,SAAS,WAAW,iBAAiB,aAAa,CAAC,UAAU;AAChE,WAAK,SAAS;AACd,WAAK,aAAa,KAAK;AAAA,IAC7B,CAAK;AAAA,EACF;AAAA,EAED,cAAc,OAAO;AACnB,SAAK,SAAS,WAAW,cAAc,YAAY,KAAK,OAAO;AAE/D,SAAK,QAAQ,MAAM,OAAO,GAAG,MAAM;AACnC,SAAK,QAAQ,MAAM,MAAM,GAAG,MAAM;AAClC,SAAK,QAAQ,MAAM,QAAQ;AAC3B,SAAK,QAAQ,MAAM,SAAS;AAE5B,SAAK,WAAW,IAAI,MAAM;AAC1B,SAAK,WAAW,IAAI,MAAM;AAAA,EAC3B;AAAA,EAED,aAAa,OAAO;AAClB,SAAK,iBAAiB,IAAI,KAAK,IAAI,KAAK,WAAW,GAAG,MAAM,OAAO;AACnE,SAAK,iBAAiB,IAAI,KAAK,IAAI,KAAK,WAAW,GAAG,MAAM,OAAO;AACnE,SAAK,aAAa,IAAI,KAAK,IAAI,KAAK,WAAW,GAAG,MAAM,OAAO;AAC/D,SAAK,aAAa,IAAI,KAAK,IAAI,KAAK,WAAW,GAAG,MAAM,OAAO;AAE/D,SAAK,QAAQ,MAAM,OAAO,GAAG,KAAK,aAAa;AAC/C,SAAK,QAAQ,MAAM,MAAM,GAAG,KAAK,aAAa;AAC9C,SAAK,QAAQ,MAAM,QAAQ,GAAG,KAAK,iBAAiB,IAAI,KAAK,aAAa;AAC1E,SAAK,QAAQ,MAAM,SAAS,GAAG,KAAK,iBAAiB,IAAI,KAAK,aAAa;AAAA,EAC5E;AAAA,EAED,eAAe;AACb,SAAK,QAAQ,cAAc,YAAY,KAAK,OAAO;AAAA,EACpD;AACH;"}
|
||||
Reference in New Issue
Block a user