Favivon - Correção

This commit is contained in:
2026-05-30 19:59:39 -03:00
parent 76ddaa815d
commit d7dfd221f0
32859 changed files with 5459654 additions and 404 deletions
+74
View File
@@ -0,0 +1,74 @@
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const THREE = require("three");
class LightProbeHelper extends THREE.Mesh {
constructor(lightProbe, size) {
const material = new THREE.ShaderMaterial({
type: "LightProbeHelperMaterial",
uniforms: {
sh: { value: lightProbe.sh.coefficients },
// by reference
intensity: { value: lightProbe.intensity }
},
vertexShader: [
"varying vec3 vNormal;",
"void main() {",
" vNormal = normalize( normalMatrix * normal );",
" gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
"}"
].join("\n"),
fragmentShader: [
"#define RECIPROCAL_PI 0.318309886",
"vec3 inverseTransformDirection( in vec3 normal, in mat4 matrix ) {",
" // matrix is assumed to be orthogonal",
" return normalize( ( vec4( normal, 0.0 ) * matrix ).xyz );",
"}",
"// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf",
"vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {",
" // normal is assumed to have unit length",
" float x = normal.x, y = normal.y, z = normal.z;",
" // band 0",
" vec3 result = shCoefficients[ 0 ] * 0.886227;",
" // band 1",
" result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;",
" result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;",
" result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;",
" // band 2",
" result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;",
" result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;",
" result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );",
" result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;",
" result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );",
" return result;",
"}",
"uniform vec3 sh[ 9 ]; // sh coefficients",
"uniform float intensity; // light probe intensity",
"varying vec3 vNormal;",
"void main() {",
" vec3 normal = normalize( vNormal );",
" vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );",
" vec3 irradiance = shGetIrradianceAt( worldNormal, sh );",
" vec3 outgoingLight = RECIPROCAL_PI * irradiance * intensity;",
" gl_FragColor = linearToOutputTexel( vec4( outgoingLight, 1.0 ) );",
"}"
].join("\n")
});
const geometry = new THREE.SphereGeometry(1, 32, 16);
super(geometry, material);
this.lightProbe = lightProbe;
this.size = size;
this.type = "LightProbeHelper";
this.onBeforeRender();
}
dispose() {
this.geometry.dispose();
this.material.dispose();
}
onBeforeRender() {
this.position.copy(this.lightProbe.position);
this.scale.set(1, 1, 1).multiplyScalar(this.size);
this.material.uniforms.intensity.value = this.lightProbe.intensity;
}
}
exports.LightProbeHelper = LightProbeHelper;
//# sourceMappingURL=LightProbeHelper.cjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"LightProbeHelper.cjs","sources":["../../src/helpers/LightProbeHelper.js"],"sourcesContent":["import { Mesh, ShaderMaterial, SphereGeometry } from 'three'\n\nclass LightProbeHelper extends Mesh {\n constructor(lightProbe, size) {\n const material = new ShaderMaterial({\n type: 'LightProbeHelperMaterial',\n\n uniforms: {\n sh: { value: lightProbe.sh.coefficients }, // by reference\n\n intensity: { value: lightProbe.intensity },\n },\n\n vertexShader: [\n 'varying vec3 vNormal;',\n\n 'void main() {',\n\n '\tvNormal = normalize( normalMatrix * normal );',\n\n '\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );',\n\n '}',\n ].join('\\n'),\n\n fragmentShader: [\n '#define RECIPROCAL_PI 0.318309886',\n\n 'vec3 inverseTransformDirection( in vec3 normal, in mat4 matrix ) {',\n\n '\t// matrix is assumed to be orthogonal',\n\n '\treturn normalize( ( vec4( normal, 0.0 ) * matrix ).xyz );',\n\n '}',\n\n '// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf',\n 'vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {',\n\n '\t// normal is assumed to have unit length',\n\n '\tfloat x = normal.x, y = normal.y, z = normal.z;',\n\n '\t// band 0',\n '\tvec3 result = shCoefficients[ 0 ] * 0.886227;',\n\n '\t// band 1',\n '\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;',\n '\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;',\n '\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;',\n\n '\t// band 2',\n '\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;',\n '\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;',\n '\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );',\n '\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;',\n '\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );',\n\n '\treturn result;',\n\n '}',\n\n 'uniform vec3 sh[ 9 ]; // sh coefficients',\n\n 'uniform float intensity; // light probe intensity',\n\n 'varying vec3 vNormal;',\n\n 'void main() {',\n\n '\tvec3 normal = normalize( vNormal );',\n\n '\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );',\n\n '\tvec3 irradiance = shGetIrradianceAt( worldNormal, sh );',\n\n '\tvec3 outgoingLight = RECIPROCAL_PI * irradiance * intensity;',\n\n '\tgl_FragColor = linearToOutputTexel( vec4( outgoingLight, 1.0 ) );',\n\n '}',\n ].join('\\n'),\n })\n\n const geometry = new SphereGeometry(1, 32, 16)\n\n super(geometry, material)\n\n this.lightProbe = lightProbe\n this.size = size\n this.type = 'LightProbeHelper'\n\n this.onBeforeRender()\n }\n\n dispose() {\n this.geometry.dispose()\n this.material.dispose()\n }\n\n onBeforeRender() {\n this.position.copy(this.lightProbe.position)\n\n this.scale.set(1, 1, 1).multiplyScalar(this.size)\n\n this.material.uniforms.intensity.value = this.lightProbe.intensity\n }\n}\n\nexport { LightProbeHelper }\n"],"names":["Mesh","ShaderMaterial","SphereGeometry"],"mappings":";;;AAE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C1D;AACH;;"}
+10
View File
@@ -0,0 +1,10 @@
import { LightProbe, Mesh } from 'three'
export class LightProbeHelper extends Mesh {
constructor(lightProbe: LightProbe, size: number)
lightProbe: LightProbe
size: number
dispose(): void
}
+74
View File
@@ -0,0 +1,74 @@
import { Mesh, ShaderMaterial, SphereGeometry } from "three";
class LightProbeHelper extends Mesh {
constructor(lightProbe, size) {
const material = new ShaderMaterial({
type: "LightProbeHelperMaterial",
uniforms: {
sh: { value: lightProbe.sh.coefficients },
// by reference
intensity: { value: lightProbe.intensity }
},
vertexShader: [
"varying vec3 vNormal;",
"void main() {",
" vNormal = normalize( normalMatrix * normal );",
" gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
"}"
].join("\n"),
fragmentShader: [
"#define RECIPROCAL_PI 0.318309886",
"vec3 inverseTransformDirection( in vec3 normal, in mat4 matrix ) {",
" // matrix is assumed to be orthogonal",
" return normalize( ( vec4( normal, 0.0 ) * matrix ).xyz );",
"}",
"// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf",
"vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {",
" // normal is assumed to have unit length",
" float x = normal.x, y = normal.y, z = normal.z;",
" // band 0",
" vec3 result = shCoefficients[ 0 ] * 0.886227;",
" // band 1",
" result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;",
" result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;",
" result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;",
" // band 2",
" result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;",
" result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;",
" result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );",
" result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;",
" result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );",
" return result;",
"}",
"uniform vec3 sh[ 9 ]; // sh coefficients",
"uniform float intensity; // light probe intensity",
"varying vec3 vNormal;",
"void main() {",
" vec3 normal = normalize( vNormal );",
" vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );",
" vec3 irradiance = shGetIrradianceAt( worldNormal, sh );",
" vec3 outgoingLight = RECIPROCAL_PI * irradiance * intensity;",
" gl_FragColor = linearToOutputTexel( vec4( outgoingLight, 1.0 ) );",
"}"
].join("\n")
});
const geometry = new SphereGeometry(1, 32, 16);
super(geometry, material);
this.lightProbe = lightProbe;
this.size = size;
this.type = "LightProbeHelper";
this.onBeforeRender();
}
dispose() {
this.geometry.dispose();
this.material.dispose();
}
onBeforeRender() {
this.position.copy(this.lightProbe.position);
this.scale.set(1, 1, 1).multiplyScalar(this.size);
this.material.uniforms.intensity.value = this.lightProbe.intensity;
}
}
export {
LightProbeHelper
};
//# sourceMappingURL=LightProbeHelper.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"LightProbeHelper.js","sources":["../../src/helpers/LightProbeHelper.js"],"sourcesContent":["import { Mesh, ShaderMaterial, SphereGeometry } from 'three'\n\nclass LightProbeHelper extends Mesh {\n constructor(lightProbe, size) {\n const material = new ShaderMaterial({\n type: 'LightProbeHelperMaterial',\n\n uniforms: {\n sh: { value: lightProbe.sh.coefficients }, // by reference\n\n intensity: { value: lightProbe.intensity },\n },\n\n vertexShader: [\n 'varying vec3 vNormal;',\n\n 'void main() {',\n\n '\tvNormal = normalize( normalMatrix * normal );',\n\n '\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );',\n\n '}',\n ].join('\\n'),\n\n fragmentShader: [\n '#define RECIPROCAL_PI 0.318309886',\n\n 'vec3 inverseTransformDirection( in vec3 normal, in mat4 matrix ) {',\n\n '\t// matrix is assumed to be orthogonal',\n\n '\treturn normalize( ( vec4( normal, 0.0 ) * matrix ).xyz );',\n\n '}',\n\n '// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf',\n 'vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {',\n\n '\t// normal is assumed to have unit length',\n\n '\tfloat x = normal.x, y = normal.y, z = normal.z;',\n\n '\t// band 0',\n '\tvec3 result = shCoefficients[ 0 ] * 0.886227;',\n\n '\t// band 1',\n '\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;',\n '\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;',\n '\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;',\n\n '\t// band 2',\n '\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;',\n '\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;',\n '\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );',\n '\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;',\n '\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );',\n\n '\treturn result;',\n\n '}',\n\n 'uniform vec3 sh[ 9 ]; // sh coefficients',\n\n 'uniform float intensity; // light probe intensity',\n\n 'varying vec3 vNormal;',\n\n 'void main() {',\n\n '\tvec3 normal = normalize( vNormal );',\n\n '\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );',\n\n '\tvec3 irradiance = shGetIrradianceAt( worldNormal, sh );',\n\n '\tvec3 outgoingLight = RECIPROCAL_PI * irradiance * intensity;',\n\n '\tgl_FragColor = linearToOutputTexel( vec4( outgoingLight, 1.0 ) );',\n\n '}',\n ].join('\\n'),\n })\n\n const geometry = new SphereGeometry(1, 32, 16)\n\n super(geometry, material)\n\n this.lightProbe = lightProbe\n this.size = size\n this.type = 'LightProbeHelper'\n\n this.onBeforeRender()\n }\n\n dispose() {\n this.geometry.dispose()\n this.material.dispose()\n }\n\n onBeforeRender() {\n this.position.copy(this.lightProbe.position)\n\n this.scale.set(1, 1, 1).multiplyScalar(this.size)\n\n this.material.uniforms.intensity.value = this.lightProbe.intensity\n }\n}\n\nexport { LightProbeHelper }\n"],"names":[],"mappings":";AAEA,MAAM,yBAAyB,KAAK;AAAA,EAClC,Y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ty(exports, Symbol.toStringTag, { value: "Module" });
const THREE = require("three");
class PositionalAudioHelper extends THREE.Line {
constructor(audio, range = 1, divisionsInnerAngle = 16, divisionsOuterAngle = 2) {
const geometry = new THREE.BufferGeometry();
const divisions = divisionsInnerAngle + divisionsOuterAngle * 2;
const positions = new Float32Array((divisions * 3 + 3) * 3);
geometry.setAttribute("position", new THREE.BufferAttribute(positions, 3));
const materialInnerAngle = new THREE.LineBasicMaterial({ color: 65280 });
const materialOuterAngle = new THREE.LineBasicMaterial({ color: 16776960 });
super(geometry, [materialOuterAngle, materialInnerAngle]);
this.type = "PositionalAudioHelper";
this.audio = audio;
this.range = range;
this.divisionsInnerAngle = divisionsInnerAngle;
this.divisionsOuterAngle = divisionsOuterAngle;
this.update();
}
update() {
const audio = this.audio;
const range = this.range;
const divisionsInnerAngle = this.divisionsInnerAngle;
const divisionsOuterAngle = this.divisionsOuterAngle;
const coneInnerAngle = THREE.MathUtils.degToRad(audio.panner.coneInnerAngle);
const coneOuterAngle = THREE.MathUtils.degToRad(audio.panner.coneOuterAngle);
const halfConeInnerAngle = coneInnerAngle / 2;
const halfConeOuterAngle = coneOuterAngle / 2;
let start = 0;
let count = 0;
let i, stride;
const geometry = this.geometry;
const positionAttribute = geometry.attributes.position;
geometry.clearGroups();
function generateSegment(from, to, divisions, materialIndex) {
const step = (to - from) / divisions;
positionAttribute.setXYZ(start, 0, 0, 0);
count++;
for (i = from; i < to; i += step) {
stride = start + count;
positionAttribute.setXYZ(stride, Math.sin(i) * range, 0, Math.cos(i) * range);
positionAttribute.setXYZ(
stride + 1,
Math.sin(Math.min(i + step, to)) * range,
0,
Math.cos(Math.min(i + step, to)) * range
);
positionAttribute.setXYZ(stride + 2, 0, 0, 0);
count += 3;
}
geometry.addGroup(start, count, materialIndex);
start += count;
count = 0;
}
generateSegment(-halfConeOuterAngle, -halfConeInnerAngle, divisionsOuterAngle, 0);
generateSegment(-halfConeInnerAngle, halfConeInnerAngle, divisionsInnerAngle, 1);
generateSegment(halfConeInnerAngle, halfConeOuterAngle, divisionsOuterAngle, 0);
positionAttribute.needsUpdate = true;
if (coneInnerAngle === coneOuterAngle)
this.material[0].visible = false;
}
dispose() {
this.geometry.dispose();
this.material[0].dispose();
this.material[1].dispose();
}
}
exports.PositionalAudioHelper = PositionalAudioHelper;
//# sourceMappingURL=PositionalAudioHelper.cjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"PositionalAudioHelper.cjs","sources":["../../src/helpers/PositionalAudioHelper.js"],"sourcesContent":["import { BufferGeometry, BufferAttribute, LineBasicMaterial, Line, MathUtils } from 'three'\n\nclass PositionalAudioHelper extends Line {\n constructor(audio, range = 1, divisionsInnerAngle = 16, divisionsOuterAngle = 2) {\n const geometry = new BufferGeometry()\n const divisions = divisionsInnerAngle + divisionsOuterAngle * 2\n const positions = new Float32Array((divisions * 3 + 3) * 3)\n geometry.setAttribute('position', new BufferAttribute(positions, 3))\n\n const materialInnerAngle = new LineBasicMaterial({ color: 0x00ff00 })\n const materialOuterAngle = new LineBasicMaterial({ color: 0xffff00 })\n\n super(geometry, [materialOuterAngle, materialInnerAngle])\n\n this.type = 'PositionalAudioHelper'\n this.audio = audio\n this.range = range\n this.divisionsInnerAngle = divisionsInnerAngle\n this.divisionsOuterAngle = divisionsOuterAngle\n\n this.update()\n }\n\n update() {\n const audio = this.audio\n const range = this.range\n const divisionsInnerAngle = this.divisionsInnerAngle\n const divisionsOuterAngle = this.divisionsOuterAngle\n\n const coneInnerAngle = MathUtils.degToRad(audio.panner.coneInnerAngle)\n const coneOuterAngle = MathUtils.degToRad(audio.panner.coneOuterAngle)\n\n const halfConeInnerAngle = coneInnerAngle / 2\n const halfConeOuterAngle = coneOuterAngle / 2\n\n let start = 0\n let count = 0\n let i, stride\n\n const geometry = this.geometry\n const positionAttribute = geometry.attributes.position\n\n geometry.clearGroups()\n\n //\n\n function generateSegment(from, to, divisions, materialIndex) {\n const step = (to - from) / divisions\n\n positionAttribute.setXYZ(start, 0, 0, 0)\n count++\n\n for (i = from; i < to; i += step) {\n stride = start + count\n\n positionAttribute.setXYZ(stride, Math.sin(i) * range, 0, Math.cos(i) * range)\n positionAttribute.setXYZ(\n stride + 1,\n Math.sin(Math.min(i + step, to)) * range,\n 0,\n Math.cos(Math.min(i + step, to)) * range,\n )\n positionAttribute.setXYZ(stride + 2, 0, 0, 0)\n\n count += 3\n }\n\n geometry.addGroup(start, count, materialIndex)\n\n start += count\n count = 0\n }\n\n //\n\n generateSegment(-halfConeOuterAngle, -halfConeInnerAngle, divisionsOuterAngle, 0)\n generateSegment(-halfConeInnerAngle, halfConeInnerAngle, divisionsInnerAngle, 1)\n generateSegment(halfConeInnerAngle, halfConeOuterAngle, divisionsOuterAngle, 0)\n\n //\n\n positionAttribute.needsUpdate = true\n\n if (coneInnerAngle === coneOuterAngle) this.material[0].visible = false\n }\n\n dispose() {\n this.geometry.dispose()\n this.material[0].dispose()\n this.material[1].dispose()\n }\n}\n\nexport { PositionalAudioHelper }\n"],"names":["Line","BufferGeometry","BufferAttribute","LineBasicMaterial","MathUtils"],"mappings":";;;AAEA,MAAM,8BAA8BA,MAAAA,KAAK;AAAA,EACvC,YAAY,OAAO,QAAQ,GAAG,sBAAsB,IAAI,sBAAsB,GAAG;AAC/E,UAAM,WAAW,IAAIC,qBAAgB;AACrC,UAAM,YAAY,sBAAsB,sBAAsB;AAC9D,UAAM,YAAY,IAAI,cAAc,YAAY,IAAI,KAAK,CAAC;AAC1D,aAAS,aAAa,YAAY,IAAIC,MAAAA,gBAAgB,WAAW,CAAC,CAAC;AAEnE,UAAM,qBAAqB,IAAIC,MAAAA,kBAAkB,EAAE,OAAO,MAAQ,CAAE;AACpE,UAAM,qBAAqB,IAAIA,MAAAA,kBAAkB,EAAE,OAAO,SAAQ,CAAE;AAEpE,UAAM,UAAU,CAAC,oBAAoB,kBAAkB,CAAC;AAExD,SAAK,OAAO;AACZ,SAAK,QAAQ;AACb,SAAK,QAAQ;AACb,SAAK,sBAAsB;AAC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BAAoB,oBAAoB,qBAAqB,CAAC;AAI9E,sBAAkB,cAAc;AAEhC,QAAI,mBAAmB;AAAgB,WAAK,SAAS,CAAC,EAAE,UAAU;AAAA,EACnE;AAAA,EAED,UAAU;AACR,SAAK,SAAS,QAAS;AACvB,SAAK,SAAS,CAAC,EAAE,QAAS;AAC1B,SAAK,SAAS,CAAC,EAAE,QAAS;AAAA,EAC3B;AACH;;"}
+13
View File
@@ -0,0 +1,13 @@
import { Line, PositionalAudio } from 'three'
export class PositionalAudioHelper extends Line {
constructor(audio: PositionalAudio, range?: number, divisionsInnerAngle?: number, divisionsOuterAngle?: number)
audio: PositionalAudio
range: number
divisionsInnerAngle: number
divisionsOuterAngle: number
dispose(): void
update(): void
}
+69
View File
@@ -0,0 +1,69 @@
import { Line, BufferGeometry, BufferAttribute, LineBasicMaterial, MathUtils } from "three";
class PositionalAudioHelper extends Line {
constructor(audio, range = 1, divisionsInnerAngle = 16, divisionsOuterAngle = 2) {
const geometry = new BufferGeometry();
const divisions = divisionsInnerAngle + divisionsOuterAngle * 2;
const positions = new Float32Array((divisions * 3 + 3) * 3);
geometry.setAttribute("position", new BufferAttribute(positions, 3));
const materialInnerAngle = new LineBasicMaterial({ color: 65280 });
const materialOuterAngle = new LineBasicMaterial({ color: 16776960 });
super(geometry, [materialOuterAngle, materialInnerAngle]);
this.type = "PositionalAudioHelper";
this.audio = audio;
this.range = range;
this.divisionsInnerAngle = divisionsInnerAngle;
this.divisionsOuterAngle = divisionsOuterAngle;
this.update();
}
update() {
const audio = this.audio;
const range = this.range;
const divisionsInnerAngle = this.divisionsInnerAngle;
const divisionsOuterAngle = this.divisionsOuterAngle;
const coneInnerAngle = MathUtils.degToRad(audio.panner.coneInnerAngle);
const coneOuterAngle = MathUtils.degToRad(audio.panner.coneOuterAngle);
const halfConeInnerAngle = coneInnerAngle / 2;
const halfConeOuterAngle = coneOuterAngle / 2;
let start = 0;
let count = 0;
let i, stride;
const geometry = this.geometry;
const positionAttribute = geometry.attributes.position;
geometry.clearGroups();
function generateSegment(from, to, divisions, materialIndex) {
const step = (to - from) / divisions;
positionAttribute.setXYZ(start, 0, 0, 0);
count++;
for (i = from; i < to; i += step) {
stride = start + count;
positionAttribute.setXYZ(stride, Math.sin(i) * range, 0, Math.cos(i) * range);
positionAttribute.setXYZ(
stride + 1,
Math.sin(Math.min(i + step, to)) * range,
0,
Math.cos(Math.min(i + step, to)) * range
);
positionAttribute.setXYZ(stride + 2, 0, 0, 0);
count += 3;
}
geometry.addGroup(start, count, materialIndex);
start += count;
count = 0;
}
generateSegment(-halfConeOuterAngle, -halfConeInnerAngle, divisionsOuterAngle, 0);
generateSegment(-halfConeInnerAngle, halfConeInnerAngle, divisionsInnerAngle, 1);
generateSegment(halfConeInnerAngle, halfConeOuterAngle, divisionsOuterAngle, 0);
positionAttribute.needsUpdate = true;
if (coneInnerAngle === coneOuterAngle)
this.material[0].visible = false;
}
dispose() {
this.geometry.dispose();
this.material[0].dispose();
this.material[1].dispose();
}
}
export {
PositionalAudioHelper
};
//# sourceMappingURL=PositionalAudioHelper.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"PositionalAudioHelper.js","sources":["../../src/helpers/PositionalAudioHelper.js"],"sourcesContent":["import { BufferGeometry, BufferAttribute, LineBasicMaterial, Line, MathUtils } from 'three'\n\nclass PositionalAudioHelper extends Line {\n constructor(audio, range = 1, divisionsInnerAngle = 16, divisionsOuterAngle = 2) {\n const geometry = new BufferGeometry()\n const divisions = divisionsInnerAngle + divisionsOuterAngle * 2\n const positions = new Float32Array((divisions * 3 + 3) * 3)\n geometry.setAttribute('position', new BufferAttribute(positions, 3))\n\n const materialInnerAngle = new LineBasicMaterial({ color: 0x00ff00 })\n const materialOuterAngle = new LineBasicMaterial({ color: 0xffff00 })\n\n super(geometry, [materialOuterAngle, materialInnerAngle])\n\n this.type = 'PositionalAudioHelper'\n this.audio = audio\n this.range = range\n this.divisionsInnerAngle = divisionsInnerAngle\n this.divisionsOuterAngle = divisionsOuterAngle\n\n this.update()\n }\n\n update() {\n const audio = this.audio\n const range = this.range\n const divisionsInnerAngle = this.divisionsInnerAngle\n const divisionsOuterAngle = this.divisionsOuterAngle\n\n const coneInnerAngle = MathUtils.degToRad(audio.panner.coneInnerAngle)\n const coneOuterAngle = MathUtils.degToRad(audio.panner.coneOuterAngle)\n\n const halfConeInnerAngle = coneInnerAngle / 2\n const halfConeOuterAngle = coneOuterAngle / 2\n\n let start = 0\n let count = 0\n let i, stride\n\n const geometry = this.geometry\n const positionAttribute = geometry.attributes.position\n\n geometry.clearGroups()\n\n //\n\n function generateSegment(from, to, divisions, materialIndex) {\n const step = (to - from) / divisions\n\n positionAttribute.setXYZ(start, 0, 0, 0)\n count++\n\n for (i = from; i < to; i += step) {\n stride = start + count\n\n positionAttribute.setXYZ(stride, Math.sin(i) * range, 0, Math.cos(i) * range)\n positionAttribute.setXYZ(\n stride + 1,\n Math.sin(Math.min(i + step, to)) * range,\n 0,\n Math.cos(Math.min(i + step, to)) * range,\n )\n positionAttribute.setXYZ(stride + 2, 0, 0, 0)\n\n count += 3\n }\n\n geometry.addGroup(start, count, materialIndex)\n\n start += count\n count = 0\n }\n\n //\n\n generateSegment(-halfConeOuterAngle, -halfConeInnerAngle, divisionsOuterAngle, 0)\n generateSegment(-halfConeInnerAngle, halfConeInnerAngle, divisionsInnerAngle, 1)\n generateSegment(halfConeInnerAngle, halfConeOuterAngle, divisionsOuterAngle, 0)\n\n //\n\n positionAttribute.needsUpdate = true\n\n if (coneInnerAngle === coneOuterAngle) this.material[0].visible = false\n }\n\n dispose() {\n this.geometry.dispose()\n this.material[0].dispose()\n this.material[1].dispose()\n }\n}\n\nexport { PositionalAudioHelper }\n"],"names":[],"mappings":";AAEA,MAAM,8BAA8B,KAAK;AAAA,EACvC,YAAY,OAAO,QAAQ,GAAG,sBAAsB,IAAI,sBAAsB,GAAG;AAC/E,UAAM,WAAW,IAAI,eAAgB;AACrC,UAAM,YAAY,sBAAsB,sBAAsB;AA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UACA,KAAK,IAAI,KAAK,IAAI,IAAI,MAAM,EAAE,CAAC,IAAI;AAAA,QACpC;AACD,0BAAkB,OAAO,SAAS,GAAG,GAAG,GAAG,CAAC;AAE5C,iBAAS;AAAA,MACV;AAED,eAAS,SAAS,OAAO,OAAO,aAAa;AAE7C,eAAS;AACT,cAAQ;AAAA,IACT;AAID,oBAAgB,CAAC,oBAAoB,CAAC,oBAAoB,qBAAqB,CAAC;AAChF,oBAAgB,CAAC,oBAAoB,oBAAoB,qBAAqB,CAAC;AAC/E,oBAAgB,oBAAoB,oBAAoB,qBAAqB,CAAC;AAI9E,sBAAkB,cAAc;AAEhC,QAAI,mBAAmB;AAAgB,WAAK,SAAS,CAAC,EAAE,UAAU;AAAA,EACnE;AAAA,EAED,UAAU;AACR,SAAK,SAAS,QAAS;AACvB,SAAK,SAAS,CAAC,EAAE,QAAS;AAC1B,SAAK,SAAS,CAAC,EAAE,QAAS;AAAA,EAC3B;AACH;"}
+134
View File
@@ -0,0 +1,134 @@
"use strict";
var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => {
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const THREE = require("three");
const _o = /* @__PURE__ */ new THREE.Object3D();
const _v = /* @__PURE__ */ new THREE.Vector3();
class RaycasterHelper extends THREE.Object3D {
constructor(raycaster, numberOfHitsToVisualize = 20) {
super();
__publicField(this, "raycaster");
__publicField(this, "hits");
__publicField(this, "origin");
__publicField(this, "near");
__publicField(this, "far");
__publicField(this, "nearToFar");
__publicField(this, "originToNear");
__publicField(this, "hitPoints");
__publicField(this, "colors", {
near: 16777215,
far: 16777215,
originToNear: 3355443,
nearToFar: 16777215,
origin: [978050, 16711771]
});
__publicField(this, "setColors", (colors) => {
const _colors = {
...this.colors,
...colors
};
this.near.material.color.set(_colors.near);
this.far.material.color.set(_colors.far);
this.nearToFar.material.color.set(_colors.nearToFar);
this.originToNear.material.color.set(_colors.originToNear);
});
__publicField(this, "update", () => {
var _a;
const origin = this.raycaster.ray.origin;
const direction = this.raycaster.ray.direction;
this.origin.position.copy(origin);
this.near.position.copy(origin).add(direction.clone().multiplyScalar(this.raycaster.near));
this.far.position.copy(origin).add(direction.clone().multiplyScalar(this.raycaster.far));
this.far.lookAt(origin);
this.near.lookAt(origin);
let pos = this.nearToFar.geometry.getAttribute("position");
pos.set([...this.near.position.toArray(), ...this.far.position.toArray()]);
pos.needsUpdate = true;
pos = this.originToNear.geometry.getAttribute("position");
pos.set([...origin.toArray(), ...this.near.position.toArray()]);
pos.needsUpdate = true;
for (let i = 0; i < this.numberOfHitsToVisualize; i++) {
const hit = (_a = this.hits) == null ? void 0 : _a[i];
if (hit) {
const { point } = hit;
_o.position.copy(point);
_o.scale.setScalar(1);
} else {
_o.scale.setScalar(0);
}
_o.updateMatrix();
this.hitPoints.setMatrixAt(i, _o.matrix);
}
this.hitPoints.instanceMatrix.needsUpdate = true;
this.origin.material.color.set(this.hits.length > 0 ? this.colors.origin[0] : this.colors.origin[1]);
});
__publicField(this, "dispose", () => {
this.origin.geometry.dispose();
this.origin.material.dispose();
this.near.geometry.dispose();
this.near.material.dispose();
this.far.geometry.dispose();
this.far.material.dispose();
this.nearToFar.geometry.dispose();
this.nearToFar.material.dispose();
this.originToNear.geometry.dispose();
this.originToNear.material.dispose();
this.hitPoints.dispose();
});
this.numberOfHitsToVisualize = numberOfHitsToVisualize;
this.raycaster = raycaster;
this.hits = [];
this.origin = new THREE.Mesh(new THREE.SphereGeometry(0.04, 32), new THREE.MeshBasicMaterial());
this.origin.name = "RaycasterHelper_origin";
this.origin.raycast = () => null;
const size = 0.1;
let geometry = new THREE.BufferGeometry();
geometry.setAttribute("position", new THREE.Float32BufferAttribute([
-size,
size,
0,
size,
size,
0,
size,
-size,
0,
-size,
-size,
0,
-size,
size,
0
], 3));
this.near = new THREE.Line(geometry, new THREE.LineBasicMaterial());
this.near.name = "RaycasterHelper_near";
this.near.raycast = () => null;
this.far = new THREE.Line(geometry, new THREE.LineBasicMaterial());
this.far.name = "RaycasterHelper_far";
this.far.raycast = () => null;
this.nearToFar = new THREE.Line(new THREE.BufferGeometry(), new THREE.LineBasicMaterial());
this.nearToFar.name = "RaycasterHelper_nearToFar";
this.nearToFar.raycast = () => null;
this.nearToFar.geometry.setFromPoints([_v, _v]);
this.originToNear = new THREE.Line(this.nearToFar.geometry.clone(), new THREE.LineBasicMaterial());
this.originToNear.name = "RaycasterHelper_originToNear";
this.originToNear.raycast = () => null;
this.hitPoints = new THREE.InstancedMesh(new THREE.SphereGeometry(0.04), new THREE.MeshBasicMaterial(), this.numberOfHitsToVisualize);
this.hitPoints.name = "RaycasterHelper_hits";
this.hitPoints.raycast = () => null;
this.add(this.nearToFar);
this.add(this.originToNear);
this.add(this.near);
this.add(this.far);
this.add(this.origin);
this.add(this.hitPoints);
this.setColors();
}
}
exports.RaycasterHelper = RaycasterHelper;
//# sourceMappingURL=RaycasterHelper.cjs.map
File diff suppressed because one or more lines are too long
+33
View File
@@ -0,0 +1,33 @@
/**
* from https://github.com/gsimone/things/tree/main/packages/three-raycaster-helper
*/
import { BufferGeometry, InstancedMesh, Intersection, Line, LineBasicMaterial, Mesh, MeshBasicMaterial, Object3D, Raycaster, SphereGeometry } from 'three';
declare class RaycasterHelper extends Object3D {
numberOfHitsToVisualize: number;
raycaster: Raycaster;
hits: Intersection[];
origin: Mesh<SphereGeometry, MeshBasicMaterial>;
near: Line<BufferGeometry, LineBasicMaterial>;
far: Line<BufferGeometry, LineBasicMaterial>;
nearToFar: Line<BufferGeometry, LineBasicMaterial>;
originToNear: Line<BufferGeometry, LineBasicMaterial>;
hitPoints: InstancedMesh;
colors: {
near: number;
far: number;
originToNear: number;
nearToFar: number;
origin: number[];
};
constructor(raycaster: Raycaster, numberOfHitsToVisualize?: number);
setColors: (colors?: Partial<{
near: number;
far: number;
originToNear: number;
nearToFar: number;
origin: number[];
}> | undefined) => void;
update: () => void;
dispose: () => void;
}
export { RaycasterHelper };
+134
View File
@@ -0,0 +1,134 @@
var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => {
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
import { Object3D, Mesh, SphereGeometry, MeshBasicMaterial, BufferGeometry, Float32BufferAttribute, Line, LineBasicMaterial, InstancedMesh, Vector3 } from "three";
const _o = /* @__PURE__ */ new Object3D();
const _v = /* @__PURE__ */ new Vector3();
class RaycasterHelper extends Object3D {
constructor(raycaster, numberOfHitsToVisualize = 20) {
super();
__publicField(this, "raycaster");
__publicField(this, "hits");
__publicField(this, "origin");
__publicField(this, "near");
__publicField(this, "far");
__publicField(this, "nearToFar");
__publicField(this, "originToNear");
__publicField(this, "hitPoints");
__publicField(this, "colors", {
near: 16777215,
far: 16777215,
originToNear: 3355443,
nearToFar: 16777215,
origin: [978050, 16711771]
});
__publicField(this, "setColors", (colors) => {
const _colors = {
...this.colors,
...colors
};
this.near.material.color.set(_colors.near);
this.far.material.color.set(_colors.far);
this.nearToFar.material.color.set(_colors.nearToFar);
this.originToNear.material.color.set(_colors.originToNear);
});
__publicField(this, "update", () => {
var _a;
const origin = this.raycaster.ray.origin;
const direction = this.raycaster.ray.direction;
this.origin.position.copy(origin);
this.near.position.copy(origin).add(direction.clone().multiplyScalar(this.raycaster.near));
this.far.position.copy(origin).add(direction.clone().multiplyScalar(this.raycaster.far));
this.far.lookAt(origin);
this.near.lookAt(origin);
let pos = this.nearToFar.geometry.getAttribute("position");
pos.set([...this.near.position.toArray(), ...this.far.position.toArray()]);
pos.needsUpdate = true;
pos = this.originToNear.geometry.getAttribute("position");
pos.set([...origin.toArray(), ...this.near.position.toArray()]);
pos.needsUpdate = true;
for (let i = 0; i < this.numberOfHitsToVisualize; i++) {
const hit = (_a = this.hits) == null ? void 0 : _a[i];
if (hit) {
const { point } = hit;
_o.position.copy(point);
_o.scale.setScalar(1);
} else {
_o.scale.setScalar(0);
}
_o.updateMatrix();
this.hitPoints.setMatrixAt(i, _o.matrix);
}
this.hitPoints.instanceMatrix.needsUpdate = true;
this.origin.material.color.set(this.hits.length > 0 ? this.colors.origin[0] : this.colors.origin[1]);
});
__publicField(this, "dispose", () => {
this.origin.geometry.dispose();
this.origin.material.dispose();
this.near.geometry.dispose();
this.near.material.dispose();
this.far.geometry.dispose();
this.far.material.dispose();
this.nearToFar.geometry.dispose();
this.nearToFar.material.dispose();
this.originToNear.geometry.dispose();
this.originToNear.material.dispose();
this.hitPoints.dispose();
});
this.numberOfHitsToVisualize = numberOfHitsToVisualize;
this.raycaster = raycaster;
this.hits = [];
this.origin = new Mesh(new SphereGeometry(0.04, 32), new MeshBasicMaterial());
this.origin.name = "RaycasterHelper_origin";
this.origin.raycast = () => null;
const size = 0.1;
let geometry = new BufferGeometry();
geometry.setAttribute("position", new Float32BufferAttribute([
-size,
size,
0,
size,
size,
0,
size,
-size,
0,
-size,
-size,
0,
-size,
size,
0
], 3));
this.near = new Line(geometry, new LineBasicMaterial());
this.near.name = "RaycasterHelper_near";
this.near.raycast = () => null;
this.far = new Line(geometry, new LineBasicMaterial());
this.far.name = "RaycasterHelper_far";
this.far.raycast = () => null;
this.nearToFar = new Line(new BufferGeometry(), new LineBasicMaterial());
this.nearToFar.name = "RaycasterHelper_nearToFar";
this.nearToFar.raycast = () => null;
this.nearToFar.geometry.setFromPoints([_v, _v]);
this.originToNear = new Line(this.nearToFar.geometry.clone(), new LineBasicMaterial());
this.originToNear.name = "RaycasterHelper_originToNear";
this.originToNear.raycast = () => null;
this.hitPoints = new InstancedMesh(new SphereGeometry(0.04), new MeshBasicMaterial(), this.numberOfHitsToVisualize);
this.hitPoints.name = "RaycasterHelper_hits";
this.hitPoints.raycast = () => null;
this.add(this.nearToFar);
this.add(this.originToNear);
this.add(this.near);
this.add(this.far);
this.add(this.origin);
this.add(this.hitPoints);
this.setColors();
}
}
export {
RaycasterHelper
};
//# sourceMappingURL=RaycasterHelper.js.map
File diff suppressed because one or more lines are too long
+45
View File
@@ -0,0 +1,45 @@
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const THREE = require("three");
class RectAreaLightHelper extends THREE.Line {
constructor(light, color) {
const positions = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0, 1, 1, 0];
const geometry = new THREE.BufferGeometry();
geometry.setAttribute("position", new THREE.Float32BufferAttribute(positions, 3));
geometry.computeBoundingSphere();
const material = new THREE.LineBasicMaterial({ fog: false });
super(geometry, material);
this.light = light;
this.color = color;
this.type = "RectAreaLightHelper";
const positions2 = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0];
const geometry2 = new THREE.BufferGeometry();
geometry2.setAttribute("position", new THREE.Float32BufferAttribute(positions2, 3));
geometry2.computeBoundingSphere();
this.add(new THREE.Mesh(geometry2, new THREE.MeshBasicMaterial({ side: THREE.BackSide, fog: false })));
}
updateMatrixWorld() {
this.scale.set(0.5 * this.light.width, 0.5 * this.light.height, 1);
if (this.color !== void 0) {
this.material.color.set(this.color);
this.children[0].material.color.set(this.color);
} else {
this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);
const c = this.material.color;
const max = Math.max(c.r, c.g, c.b);
if (max > 1)
c.multiplyScalar(1 / max);
this.children[0].material.color.copy(this.material.color);
}
this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld);
this.children[0].matrixWorld.copy(this.matrixWorld);
}
dispose() {
this.geometry.dispose();
this.material.dispose();
this.children[0].geometry.dispose();
this.children[0].material.dispose();
}
}
exports.RectAreaLightHelper = RectAreaLightHelper;
//# sourceMappingURL=RectAreaLightHelper.cjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"RectAreaLightHelper.cjs","sources":["../../src/helpers/RectAreaLightHelper.js"],"sourcesContent":["import {\n BackSide,\n BufferGeometry,\n Float32BufferAttribute,\n Line,\n LineBasicMaterial,\n Mesh,\n MeshBasicMaterial,\n} from 'three'\n\n/**\n * This helper must be added as a child of the light\n */\n\nclass RectAreaLightHelper extends Line {\n constructor(light, color) {\n const positions = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0, 1, 1, 0]\n\n const geometry = new BufferGeometry()\n geometry.setAttribute('position', new Float32BufferAttribute(positions, 3))\n geometry.computeBoundingSphere()\n\n const material = new LineBasicMaterial({ fog: false })\n\n super(geometry, material)\n\n this.light = light\n this.color = color // optional hardwired color for the helper\n this.type = 'RectAreaLightHelper'\n\n //\n\n const positions2 = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0]\n\n const geometry2 = new BufferGeometry()\n geometry2.setAttribute('position', new Float32BufferAttribute(positions2, 3))\n geometry2.computeBoundingSphere()\n\n this.add(new Mesh(geometry2, new MeshBasicMaterial({ side: BackSide, fog: false })))\n }\n\n updateMatrixWorld() {\n this.scale.set(0.5 * this.light.width, 0.5 * this.light.height, 1)\n\n if (this.color !== undefined) {\n this.material.color.set(this.color)\n this.children[0].material.color.set(this.color)\n } else {\n this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity)\n\n // prevent hue shift\n const c = this.material.color\n const max = Math.max(c.r, c.g, c.b)\n if (max > 1) c.multiplyScalar(1 / max)\n\n this.children[0].material.color.copy(this.material.color)\n }\n\n // ignore world scale on light\n this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld)\n\n this.children[0].matrixWorld.copy(this.matrixWorld)\n }\n\n dispose() {\n this.geometry.dispose()\n this.material.dispose()\n this.children[0].geometry.dispose()\n this.children[0].material.dispose()\n }\n}\n\nexport { RectAreaLightHelper }\n"],"names":["Line","BufferGeometry","Float32BufferAttribute","LineBasicMaterial","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ACxB,YAAM,MAAM,KAAK,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAClC,UAAI,MAAM;AAAG,UAAE,eAAe,IAAI,GAAG;AAErC,WAAK,SAAS,CAAC,EAAE,SAAS,MAAM,KAAK,KAAK,SAAS,KAAK;AAAA,IACzD;AAGD,SAAK,YAAY,gBAAgB,KAAK,MAAM,WAAW,EAAE,MAAM,KAAK,KAAK,EAAE,aAAa,KAAK,MAAM,WAAW;AAE9G,SAAK,SAAS,CAAC,EAAE,YAAY,KAAK,KAAK,WAAW;AAAA,EACnD;AAAA,EAED,UAAU;AACR,SAAK,SAAS,QAAS;AACvB,SAAK,SAAS,QAAS;AACvB,SAAK,SAAS,CAAC,EAAE,SAAS,QAAS;AACnC,SAAK,SAAS,CAAC,EAAE,SAAS,QAAS;AAAA,EACpC;AACH;;"}
+11
View File
@@ -0,0 +1,11 @@
import { Line, RectAreaLight, Color } from 'three'
export class RectAreaLightHelper extends Line {
readonly type: 'RectAreaLightHelper'
constructor(light: RectAreaLight, color?: Color | string | number)
light: RectAreaLight
color: Color | string | number | undefined
dispose(): void
}
+45
View File
@@ -0,0 +1,45 @@
import { Line, BufferGeometry, Float32BufferAttribute, LineBasicMaterial, Mesh, MeshBasicMaterial, BackSide } from "three";
class RectAreaLightHelper extends Line {
constructor(light, color) {
const positions = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0, 1, 1, 0];
const geometry = new BufferGeometry();
geometry.setAttribute("position", new Float32BufferAttribute(positions, 3));
geometry.computeBoundingSphere();
const material = new LineBasicMaterial({ fog: false });
super(geometry, material);
this.light = light;
this.color = color;
this.type = "RectAreaLightHelper";
const positions2 = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0];
const geometry2 = new BufferGeometry();
geometry2.setAttribute("position", new Float32BufferAttribute(positions2, 3));
geometry2.computeBoundingSphere();
this.add(new Mesh(geometry2, new MeshBasicMaterial({ side: BackSide, fog: false })));
}
updateMatrixWorld() {
this.scale.set(0.5 * this.light.width, 0.5 * this.light.height, 1);
if (this.color !== void 0) {
this.material.color.set(this.color);
this.children[0].material.color.set(this.color);
} else {
this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);
const c = this.material.color;
const max = Math.max(c.r, c.g, c.b);
if (max > 1)
c.multiplyScalar(1 / max);
this.children[0].material.color.copy(this.material.color);
}
this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld);
this.children[0].matrixWorld.copy(this.matrixWorld);
}
dispose() {
this.geometry.dispose();
this.material.dispose();
this.children[0].geometry.dispose();
this.children[0].material.dispose();
}
}
export {
RectAreaLightHelper
};
//# sourceMappingURL=RectAreaLightHelper.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"RectAreaLightHelper.js","sources":["../../src/helpers/RectAreaLightHelper.js"],"sourcesContent":["import {\n BackSide,\n BufferGeometry,\n Float32BufferAttribute,\n Line,\n LineBasicMaterial,\n Mesh,\n MeshBasicMaterial,\n} from 'three'\n\n/**\n * This helper must be added as a child of the light\n */\n\nclass RectAreaLightHelper extends Line {\n constructor(light, color) {\n const positions = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0, 1, 1, 0]\n\n const geometry = new BufferGeometry()\n geometry.setAttribute('position', new Float32BufferAttribute(positions, 3))\n geometry.computeBoundingSphere()\n\n const material = new LineBasicMaterial({ fog: false })\n\n super(geometry, material)\n\n this.light = light\n this.color = color // optional hardwired color for the helper\n this.type = 'RectAreaLightHelper'\n\n //\n\n const positions2 = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0]\n\n const geometry2 = new BufferGeometry()\n geometry2.setAttribute('position', new Float32BufferAttribute(positions2, 3))\n geometry2.computeBoundingSphere()\n\n this.add(new Mesh(geometry2, new MeshBasicMaterial({ side: BackSide, fog: false })))\n }\n\n updateMatrixWorld() {\n this.scale.set(0.5 * this.light.width, 0.5 * this.light.height, 1)\n\n if (this.color !== undefined) {\n this.material.color.set(this.color)\n this.children[0].material.color.set(this.color)\n } else {\n this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity)\n\n // prevent hue shift\n const c = this.material.color\n const max = Math.max(c.r, c.g, c.b)\n if (max > 1) c.multiplyScalar(1 / max)\n\n this.children[0].material.color.copy(this.material.color)\n }\n\n // ignore world scale on light\n this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld)\n\n this.children[0].matrixWorld.copy(this.matrixWorld)\n }\n\n dispose() {\n this.geometry.dispose()\n this.material.dispose()\n this.children[0].geometry.dispose()\n this.children[0].material.dispose()\n }\n}\n\nexport { RectAreaLightHelper }\n"],"names":[],"mappings":";AAcA,MAAM,4BAA4B,KAAK;AAAA,EACrC,YAAY,OAAO,OAAO;AACxB,UAAM,YAAY,CAAC,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,IAAI,IAAI,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,CAAC;AAElE,UAAM,WAAW,IAAI,eAAgB;AACrC,aAAS,aAAa,YAAY,IAAI,uBAAuB,WAAW,CAAC,CAAC;AAC1E,aAAS,sBAAuB;AAEhC,UAAM,WAAW,IAAI,kBAAkB,EAAE,KAAK,MAAK,CAAE;AAErD,UAAM,UAAU,QAAQ;AAExB,SAAK,QAAQ;AACb,SAAK,QAAQ;AACb,SAAK,OAAO;AAIZ,UAAM,aAAa,CAAC,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,IAAI,IAAI,GAAG,GAAG,GAAG,GAAG,IAAI,IAAI,GAAG,GAAG,IAAI,CAAC;AAE9E,UAAM,YAAY,IAAI,eAAgB;AACtC,cAAU,aAAa,YAAY,IAAI,uBAAuB,YAAY,CAAC,CAAC;AAC5E,cAAU,sBAAuB;AAEjC,SAAK,IAAI,IAAI,KAAK,WAAW,IAAI,kBAAkB,EAAE,MAAM,UAAU,KAAK,MAAK,CAAE,CAAC,CAAC;AAAA,EACpF;AAAA,EAED,oBAAoB;AAClB,SAAK,MAAM,IAAI,MAAM,KAAK,MAAM,OAAO,MAAM,KAAK,MAAM,QAAQ,CAAC;AAEjE,QAAI,KAAK,UAAU,QAAW;AAC5B,WAAK,SAAS,MAAM,IAAI,KAAK,KAAK;AAClC,WAAK,SAAS,CAAC,EAAE,SAAS,MAAM,IAAI,KAAK,KAAK;AAAA,IACpD,OAAW;AACL,WAAK,SAAS,MAAM,KAAK,KAAK,MAAM,KAAK,EAAE,eAAe,KAAK,MAAM,SAAS;AAG9E,YAAM,IAAI,KAAK,SAAS;AACxB,YAAM,MAAM,KAAK,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAClC,UAAI,MAAM;AAAG,UAAE,eAAe,IAAI,GAAG;AAErC,WAAK,SAAS,CAAC,EAAE,SAAS,MAAM,KAAK,KAAK,SAAS,KAAK;AAAA,IACzD;AAGD,SAAK,YAAY,gBAAgB,KAAK,MAAM,WAAW,EAAE,MAAM,KAAK,KAAK,EAAE,aAAa,KAAK,MAAM,WAAW;AAE9G,SAAK,SAAS,CAAC,EAAE,YAAY,KAAK,KAAK,WAAW;AAAA,EACnD;AAAA,EAED,UAAU;AACR,SAAK,SAAS,QAAS;AACvB,SAAK,SAAS,QAAS;AACvB,SAAK,SAAS,CAAC,EAAE,SAAS,QAAS;AACnC,SAAK,SAAS,CAAC,EAAE,SAAS,QAAS;AAAA,EACpC;AACH;"}
+48
View File
@@ -0,0 +1,48 @@
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const THREE = require("three");
const _v1 = /* @__PURE__ */ new THREE.Vector3();
const _v2 = /* @__PURE__ */ new THREE.Vector3();
const _normalMatrix = /* @__PURE__ */ new THREE.Matrix3();
class VertexNormalsHelper extends THREE.LineSegments {
constructor(object, size = 1, color = 16711680) {
const geometry = new THREE.BufferGeometry();
const nNormals = object.geometry.attributes.normal.count;
const positions = new THREE.Float32BufferAttribute(nNormals * 2 * 3, 3);
geometry.setAttribute("position", positions);
super(geometry, new THREE.LineBasicMaterial({ color, toneMapped: false }));
this.object = object;
this.size = size;
this.type = "VertexNormalsHelper";
this.matrixAutoUpdate = false;
this.update();
}
update() {
this.object.updateMatrixWorld(true);
_normalMatrix.getNormalMatrix(this.object.matrixWorld);
const matrixWorld = this.object.matrixWorld;
const position = this.geometry.attributes.position;
const objGeometry = this.object.geometry;
if (objGeometry) {
const objPos = objGeometry.attributes.position;
const objNorm = objGeometry.attributes.normal;
let idx = 0;
for (let j = 0, jl = objPos.count; j < jl; j++) {
_v1.fromBufferAttribute(objPos, j).applyMatrix4(matrixWorld);
_v2.fromBufferAttribute(objNorm, j);
_v2.applyMatrix3(_normalMatrix).normalize().multiplyScalar(this.size).add(_v1);
position.setXYZ(idx, _v1.x, _v1.y, _v1.z);
idx = idx + 1;
position.setXYZ(idx, _v2.x, _v2.y, _v2.z);
idx = idx + 1;
}
}
position.needsUpdate = true;
}
dispose() {
this.geometry.dispose();
this.material.dispose();
}
}
exports.VertexNormalsHelper = VertexNormalsHelper;
//# sourceMappingURL=VertexNormalsHelper.cjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"VertexNormalsHelper.cjs","sources":["../../src/helpers/VertexNormalsHelper.js"],"sourcesContent":["import { BufferGeometry, Float32BufferAttribute, LineSegments, LineBasicMaterial, Matrix3, Vector3 } from 'three'\n\nconst _v1 = /* @__PURE__ */ new Vector3()\nconst _v2 = /* @__PURE__ */ new Vector3()\nconst _normalMatrix = /* @__PURE__ */ new Matrix3()\n\nclass VertexNormalsHelper extends LineSegments {\n constructor(object, size = 1, color = 0xff0000) {\n const geometry = new BufferGeometry()\n\n const nNormals = object.geometry.attributes.normal.count\n const positions = new Float32BufferAttribute(nNormals * 2 * 3, 3)\n\n geometry.setAttribute('position', positions)\n\n super(geometry, new LineBasicMaterial({ color, toneMapped: false }))\n\n this.object = object\n this.size = size\n this.type = 'VertexNormalsHelper'\n\n //\n\n this.matrixAutoUpdate = false\n\n this.update()\n }\n\n update() {\n this.object.updateMatrixWorld(true)\n\n _normalMatrix.getNormalMatrix(this.object.matrixWorld)\n\n const matrixWorld = this.object.matrixWorld\n\n const position = this.geometry.attributes.position\n\n //\n\n const objGeometry = this.object.geometry\n\n if (objGeometry) {\n const objPos = objGeometry.attributes.position\n\n const objNorm = objGeometry.attributes.normal\n\n let idx = 0\n\n // for simplicity, ignore index and drawcalls, and render every normal\n\n for (let j = 0, jl = objPos.count; j < jl; j++) {\n _v1.fromBufferAttribute(objPos, j).applyMatrix4(matrixWorld)\n\n _v2.fromBufferAttribute(objNorm, j)\n\n _v2.applyMatrix3(_normalMatrix).normalize().multiplyScalar(this.size).add(_v1)\n\n position.setXYZ(idx, _v1.x, _v1.y, _v1.z)\n\n idx = idx + 1\n\n position.setXYZ(idx, _v2.x, _v2.y, _v2.z)\n\n idx = idx + 1\n }\n }\n\n position.needsUpdate = true\n }\n\n dispose() {\n this.geometry.dispose()\n this.material.dispose()\n }\n}\n\nexport { VertexNormalsHelper }\n"],"names":["Vector3","Matrix3","LineSegments","BufferGeometry","Float32BufferAttribute","LineBasicMaterial"],"mappings":";;;AAEA,MAAM,MAAsB,oBAAIA,MAAAA,QAAS;AACzC,MAAM,MAAsB,oBAAIA,MAAAA,QAAS;AACzC,MAAM,gBAAgC,oBAAIC,MAAAA,QAAS;AAEnD,MAAM,4BAA4BC,MAAAA,aAAa;AAAA,EAC7C,YAAY,QAAQ,OAAO,GAAG,QAAQ,UAAU;AAC9C,UAAM,WAAW,IAAIC,qBAAgB;AAErC,UAAM,WAAW,OAAO,SAAS,WAAW,OAAO;AACnD,UAAM,YAAY,IAAIC,MAAsB,uBAAC,WAAW,IAAI,GAAG,CAAC;AAEhE,aAAS,aAAa,YAAY,SAAS;AAE3C,UAAM,UAAU,IAAIC,MAAiB,kBAAC,EAAE,OAAO,YAAY,MAAK,CAAE,CAAC;AAEnE,SAAK,SAAS;AACd,SAAK,OAAO;AACZ,SAAK,OAAO;AAIZ,SAAK,mBAAmB;AAExB,SAAK,OAAQ;AAAA,EACd;AAAA,EAED,SAAS;AACP,SAAK,OAAO,kBAAkB,IAAI;AAElC,kBAAc,gBAAgB,KAAK,OAAO,WAAW;AAErD,UAAM,cAAc,KAAK,OAAO;AAEhC,UAAM,WAAW,KAAK,SAAS,WAAW;AAI1C,UAAM,cAAc,KAAK,OAAO;AAEhC,QAAI,aAAa;AACf,YAAM,SAAS,YAAY,WAAW;AAEtC,YAAM,UAAU,YAAY,WAAW;AAEvC,UAAI,MAAM;AAIV,eAAS,IAAI,GAAG,KAAK,OAAO,OAAO,IAAI,IAAI,KAAK;AAC9C,YAAI,oBAAoB,QAAQ,CAAC,EAAE,aAAa,WAAW;AAE3D,YAAI,oBAAoB,SAAS,CAAC;AAElC,YAAI,aAAa,aAAa,EAAE,UAAW,EAAC,eAAe,KAAK,IAAI,EAAE,IAAI,GAAG;AAE7E,iBAAS,OAAO,KAAK,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAExC,cAAM,MAAM;AAEZ,iBAAS,OAAO,KAAK,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAExC,cAAM,MAAM;AAAA,MACb;AAAA,IACF;AAED,aAAS,cAAc;AAAA,EACxB;AAAA,EAED,UAAU;AACR,SAAK,SAAS,QAAS;AACvB,SAAK,SAAS,QAAS;AAAA,EACxB;AACH;;"}
+13
View File
@@ -0,0 +1,13 @@
import { Object3D, LineSegments } from 'three'
export class VertexNormalsHelper extends LineSegments {
readonly type: 'VertexNormalsHelper'
constructor(object: Object3D, size?: number, hex?: number)
object: Object3D
size: number
update(): void
dispose(): void
}
+48
View File
@@ -0,0 +1,48 @@
import { LineSegments, BufferGeometry, Float32BufferAttribute, LineBasicMaterial, Vector3, Matrix3 } from "three";
const _v1 = /* @__PURE__ */ new Vector3();
const _v2 = /* @__PURE__ */ new Vector3();
const _normalMatrix = /* @__PURE__ */ new Matrix3();
class VertexNormalsHelper extends LineSegments {
constructor(object, size = 1, color = 16711680) {
const geometry = new BufferGeometry();
const nNormals = object.geometry.attributes.normal.count;
const positions = new Float32BufferAttribute(nNormals * 2 * 3, 3);
geometry.setAttribute("position", positions);
super(geometry, new LineBasicMaterial({ color, toneMapped: false }));
this.object = object;
this.size = size;
this.type = "VertexNormalsHelper";
this.matrixAutoUpdate = false;
this.update();
}
update() {
this.object.updateMatrixWorld(true);
_normalMatrix.getNormalMatrix(this.object.matrixWorld);
const matrixWorld = this.object.matrixWorld;
const position = this.geometry.attributes.position;
const objGeometry = this.object.geometry;
if (objGeometry) {
const objPos = objGeometry.attributes.position;
const objNorm = objGeometry.attributes.normal;
let idx = 0;
for (let j = 0, jl = objPos.count; j < jl; j++) {
_v1.fromBufferAttribute(objPos, j).applyMatrix4(matrixWorld);
_v2.fromBufferAttribute(objNorm, j);
_v2.applyMatrix3(_normalMatrix).normalize().multiplyScalar(this.size).add(_v1);
position.setXYZ(idx, _v1.x, _v1.y, _v1.z);
idx = idx + 1;
position.setXYZ(idx, _v2.x, _v2.y, _v2.z);
idx = idx + 1;
}
}
position.needsUpdate = true;
}
dispose() {
this.geometry.dispose();
this.material.dispose();
}
}
export {
VertexNormalsHelper
};
//# sourceMappingURL=VertexNormalsHelper.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"VertexNormalsHelper.js","sources":["../../src/helpers/VertexNormalsHelper.js"],"sourcesContent":["import { BufferGeometry, Float32BufferAttribute, LineSegments, LineBasicMaterial, Matrix3, Vector3 } from 'three'\n\nconst _v1 = /* @__PURE__ */ new Vector3()\nconst _v2 = /* @__PURE__ */ new Vector3()\nconst _normalMatrix = /* @__PURE__ */ new Matrix3()\n\nclass VertexNormalsHelper extends LineSegments {\n constructor(object, size = 1, color = 0xff0000) {\n const geometry = new BufferGeometry()\n\n const nNormals = object.geometry.attributes.normal.count\n const positions = new Float32BufferAttribute(nNormals * 2 * 3, 3)\n\n geometry.setAttribute('position', positions)\n\n super(geometry, new LineBasicMaterial({ color, toneMapped: false }))\n\n this.object = object\n this.size = size\n this.type = 'VertexNormalsHelper'\n\n //\n\n this.matrixAutoUpdate = false\n\n this.update()\n }\n\n update() {\n this.object.updateMatrixWorld(true)\n\n _normalMatrix.getNormalMatrix(this.object.matrixWorld)\n\n const matrixWorld = this.object.matrixWorld\n\n const position = this.geometry.attributes.position\n\n //\n\n const objGeometry = this.object.geometry\n\n if (objGeometry) {\n const objPos = objGeometry.attributes.position\n\n const objNorm = objGeometry.attributes.normal\n\n let idx = 0\n\n // for simplicity, ignore index and drawcalls, and render every normal\n\n for (let j = 0, jl = objPos.count; j < jl; j++) {\n _v1.fromBufferAttribute(objPos, j).applyMatrix4(matrixWorld)\n\n _v2.fromBufferAttribute(objNorm, j)\n\n _v2.applyMatrix3(_normalMatrix).normalize().multiplyScalar(this.size).add(_v1)\n\n position.setXYZ(idx, _v1.x, _v1.y, _v1.z)\n\n idx = idx + 1\n\n position.setXYZ(idx, _v2.x, _v2.y, _v2.z)\n\n idx = idx + 1\n }\n }\n\n position.needsUpdate = true\n }\n\n dispose() {\n this.geometry.dispose()\n this.material.dispose()\n }\n}\n\nexport { VertexNormalsHelper }\n"],"names":[],"mappings":";AAEA,MAAM,MAAsB,oBAAI,QAAS;AACzC,MAAM,MAAsB,oBAAI,QAAS;AACzC,MAAM,gBAAgC,oBAAI,QAAS;AAEnD,MAAM,4BAA4B,aAAa;AAAA,EAC7C,YAAY,QAAQ,OAAO,GAAG,QAAQ,UAAU;AAC9C,UAAM,WAAW,IAAI,eAAgB;AAErC,UAAM,WAAW,OAAO,SAAS,WAAW,OAAO;AACnD,UAAM,YAAY,IAAI,uBAAuB,WAAW,IAAI,GAAG,CAAC;AAEhE,aAAS,aAAa,YAAY,SAAS;AAE3C,UAAM,UAAU,IAAI,kBAAkB,EAAE,OAAO,YAAY,MAAK,CAAE,CAAC;AAEnE,SAAK,SAAS;AACd,SAAK,OAAO;AACZ,SAAK,OAAO;AAIZ,SAAK,mBAAmB;AAExB,SAAK,OAAQ;AAAA,EACd;AAAA,EAED,SAAS;AACP,SAAK,OAAO,kBAAkB,IAAI;AAElC,kBAAc,gBAAgB,KAAK,OAAO,WAAW;AAErD,UAAM,cAAc,KAAK,OAAO;AAEhC,UAAM,WAAW,KAAK,SAAS,WAAW;AAI1C,UAAM,cAAc,KAAK,OAAO;AAEhC,QAAI,aAAa;AACf,YAAM,SAAS,YAAY,WAAW;AAEtC,YAAM,UAAU,YAAY,WAAW;AAEvC,UAAI,MAAM;AAIV,eAAS,IAAI,GAAG,KAAK,OAAO,OAAO,IAAI,IAAI,KAAK;AAC9C,YAAI,oBAAoB,QAAQ,CAAC,EAAE,aAAa,WAAW;AAE3D,YAAI,oBAAoB,SAAS,CAAC;AAElC,YAAI,aAAa,aAAa,EAAE,UAAW,EAAC,eAAe,KAAK,IAAI,EAAE,IAAI,GAAG;AAE7E,iBAAS,OAAO,KAAK,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAExC,cAAM,MAAM;AAEZ,iBAAS,OAAO,KAAK,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAExC,cAAM,MAAM;AAAA,MACb;AAAA,IACF;AAED,aAAS,cAAc;AAAA,EACxB;AAAA,EAED,UAAU;AACR,SAAK,SAAS,QAAS;AACvB,SAAK,SAAS,QAAS;AAAA,EACxB;AACH;"}
+44
View File
@@ -0,0 +1,44 @@
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const THREE = require("three");
const _v1 = /* @__PURE__ */ new THREE.Vector3();
const _v2 = /* @__PURE__ */ new THREE.Vector3();
class VertexTangentsHelper extends THREE.LineSegments {
constructor(object, size = 1, color = 65535) {
const geometry = new THREE.BufferGeometry();
const nTangents = object.geometry.attributes.tangent.count;
const positions = new THREE.Float32BufferAttribute(nTangents * 2 * 3, 3);
geometry.setAttribute("position", positions);
super(geometry, new THREE.LineBasicMaterial({ color, toneMapped: false }));
this.object = object;
this.size = size;
this.type = "VertexTangentsHelper";
this.matrixAutoUpdate = false;
this.update();
}
update() {
this.object.updateMatrixWorld(true);
const matrixWorld = this.object.matrixWorld;
const position = this.geometry.attributes.position;
const objGeometry = this.object.geometry;
const objPos = objGeometry.attributes.position;
const objTan = objGeometry.attributes.tangent;
let idx = 0;
for (let j = 0, jl = objPos.count; j < jl; j++) {
_v1.fromBufferAttribute(objPos, j).applyMatrix4(matrixWorld);
_v2.fromBufferAttribute(objTan, j);
_v2.transformDirection(matrixWorld).multiplyScalar(this.size).add(_v1);
position.setXYZ(idx, _v1.x, _v1.y, _v1.z);
idx = idx + 1;
position.setXYZ(idx, _v2.x, _v2.y, _v2.z);
idx = idx + 1;
}
position.needsUpdate = true;
}
dispose() {
this.geometry.dispose();
this.material.dispose();
}
}
exports.VertexTangentsHelper = VertexTangentsHelper;
//# sourceMappingURL=VertexTangentsHelper.cjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"VertexTangentsHelper.cjs","sources":["../../src/helpers/VertexTangentsHelper.js"],"sourcesContent":["import { BufferGeometry, Float32BufferAttribute, LineSegments, LineBasicMaterial, Vector3 } from 'three'\n\nconst _v1 = /* @__PURE__ */ new Vector3()\nconst _v2 = /* @__PURE__ */ new Vector3()\n\nclass VertexTangentsHelper extends LineSegments {\n constructor(object, size = 1, color = 0x00ffff) {\n const geometry = new BufferGeometry()\n\n const nTangents = object.geometry.attributes.tangent.count\n const positions = new Float32BufferAttribute(nTangents * 2 * 3, 3)\n\n geometry.setAttribute('position', positions)\n\n super(geometry, new LineBasicMaterial({ color, toneMapped: false }))\n\n this.object = object\n this.size = size\n this.type = 'VertexTangentsHelper'\n\n //\n\n this.matrixAutoUpdate = false\n\n this.update()\n }\n\n update() {\n this.object.updateMatrixWorld(true)\n\n const matrixWorld = this.object.matrixWorld\n\n const position = this.geometry.attributes.position\n\n //\n\n const objGeometry = this.object.geometry\n\n const objPos = objGeometry.attributes.position\n\n const objTan = objGeometry.attributes.tangent\n\n let idx = 0\n\n // for simplicity, ignore index and drawcalls, and render every tangent\n\n for (let j = 0, jl = objPos.count; j < jl; j++) {\n _v1.fromBufferAttribute(objPos, j).applyMatrix4(matrixWorld)\n\n _v2.fromBufferAttribute(objTan, j)\n\n _v2.transformDirection(matrixWorld).multiplyScalar(this.size).add(_v1)\n\n position.setXYZ(idx, _v1.x, _v1.y, _v1.z)\n\n idx = idx + 1\n\n position.setXYZ(idx, _v2.x, _v2.y, _v2.z)\n\n idx = idx + 1\n }\n\n position.needsUpdate = true\n }\n\n dispose() {\n this.geometry.dispose()\n this.material.dispose()\n }\n}\n\nexport { VertexTangentsHelper }\n"],"names":["Vector3","LineSegments","BufferGeometry","Float32BufferAttribute","LineBasicMaterial"],"mappings":";;;AAEA,MAAM,MAAsB,oBAAIA,MAAAA,QAAS;AACzC,MAAM,MAAsB,oBAAIA,MAAAA,QAAS;AAEzC,MAAM,6BAA6BC,MAAAA,aAAa;AAAA,EAC9C,YAAY,QAAQ,OAAO,GAAG,QAAQ,OAAU;AAC9C,UAAM,WAAW,IAAIC,qBAAgB;AAErC,UAAM,YAAY,OAAO,SAAS,WAAW,QAAQ;AACrD,UAAM,YAAY,IAAIC,MAAsB,uBAAC,YAAY,IAAI,GAAG,CAAC;AAEjE,aAAS,aAAa,YAAY,SAAS;AAE3C,UAAM,UAAU,IAAIC,MAAiB,kBAAC,EAAE,OAAO,YAAY,MAAK,CAAE,CAAC;AAEnE,SAAK,SAAS;AACd,SAAK,OAAO;AACZ,SAAK,OAAO;AAIZ,SAAK,mBAAmB;AAExB,SAAK,OAAQ;AAAA,EACd;AAAA,EAED,SAAS;AACP,SAAK,OAAO,kBAAkB,IAAI;AAElC,UAAM,cAAc,KAAK,OAAO;AAEhC,UAAM,WAAW,KAAK,SAAS,WAAW;AAI1C,UAAM,cAAc,KAAK,OAAO;AAEhC,UAAM,SAAS,YAAY,WAAW;AAEtC,UAAM,SAAS,YAAY,WAAW;AAEtC,QAAI,MAAM;AAIV,aAAS,IAAI,GAAG,KAAK,OAAO,OAAO,IAAI,IAAI,KAAK;AAC9C,UAAI,oBAAoB,QAAQ,CAAC,EAAE,aAAa,WAAW;AAE3D,UAAI,oBAAoB,QAAQ,CAAC;AAEjC,UAAI,mBAAmB,WAAW,EAAE,eAAe,KAAK,IAAI,EAAE,IAAI,GAAG;AAErE,eAAS,OAAO,KAAK,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAExC,YAAM,MAAM;AAEZ,eAAS,OAAO,KAAK,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAExC,YAAM,MAAM;AAAA,IACb;AAED,aAAS,cAAc;AAAA,EACxB;AAAA,EAED,UAAU;AACR,SAAK,SAAS,QAAS;AACvB,SAAK,SAAS,QAAS;AAAA,EACxB;AACH;;"}
+13
View File
@@ -0,0 +1,13 @@
import { Object3D, LineSegments } from 'three'
export class VertexTangentsHelper extends LineSegments {
readonly type: 'VertexTangentsHelper'
constructor(object: Object3D, size?: number, hex?: number)
object: Object3D
size: number
update(): void
dispose(): void
}
+44
View File
@@ -0,0 +1,44 @@
import { LineSegments, BufferGeometry, Float32BufferAttribute, LineBasicMaterial, Vector3 } from "three";
const _v1 = /* @__PURE__ */ new Vector3();
const _v2 = /* @__PURE__ */ new Vector3();
class VertexTangentsHelper extends LineSegments {
constructor(object, size = 1, color = 65535) {
const geometry = new BufferGeometry();
const nTangents = object.geometry.attributes.tangent.count;
const positions = new Float32BufferAttribute(nTangents * 2 * 3, 3);
geometry.setAttribute("position", positions);
super(geometry, new LineBasicMaterial({ color, toneMapped: false }));
this.object = object;
this.size = size;
this.type = "VertexTangentsHelper";
this.matrixAutoUpdate = false;
this.update();
}
update() {
this.object.updateMatrixWorld(true);
const matrixWorld = this.object.matrixWorld;
const position = this.geometry.attributes.position;
const objGeometry = this.object.geometry;
const objPos = objGeometry.attributes.position;
const objTan = objGeometry.attributes.tangent;
let idx = 0;
for (let j = 0, jl = objPos.count; j < jl; j++) {
_v1.fromBufferAttribute(objPos, j).applyMatrix4(matrixWorld);
_v2.fromBufferAttribute(objTan, j);
_v2.transformDirection(matrixWorld).multiplyScalar(this.size).add(_v1);
position.setXYZ(idx, _v1.x, _v1.y, _v1.z);
idx = idx + 1;
position.setXYZ(idx, _v2.x, _v2.y, _v2.z);
idx = idx + 1;
}
position.needsUpdate = true;
}
dispose() {
this.geometry.dispose();
this.material.dispose();
}
}
export {
VertexTangentsHelper
};
//# sourceMappingURL=VertexTangentsHelper.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"VertexTangentsHelper.js","sources":["../../src/helpers/VertexTangentsHelper.js"],"sourcesContent":["import { BufferGeometry, Float32BufferAttribute, LineSegments, LineBasicMaterial, Vector3 } from 'three'\n\nconst _v1 = /* @__PURE__ */ new Vector3()\nconst _v2 = /* @__PURE__ */ new Vector3()\n\nclass VertexTangentsHelper extends LineSegments {\n constructor(object, size = 1, color = 0x00ffff) {\n const geometry = new BufferGeometry()\n\n const nTangents = object.geometry.attributes.tangent.count\n const positions = new Float32BufferAttribute(nTangents * 2 * 3, 3)\n\n geometry.setAttribute('position', positions)\n\n super(geometry, new LineBasicMaterial({ color, toneMapped: false }))\n\n this.object = object\n this.size = size\n this.type = 'VertexTangentsHelper'\n\n //\n\n this.matrixAutoUpdate = false\n\n this.update()\n }\n\n update() {\n this.object.updateMatrixWorld(true)\n\n const matrixWorld = this.object.matrixWorld\n\n const position = this.geometry.attributes.position\n\n //\n\n const objGeometry = this.object.geometry\n\n const objPos = objGeometry.attributes.position\n\n const objTan = objGeometry.attributes.tangent\n\n let idx = 0\n\n // for simplicity, ignore index and drawcalls, and render every tangent\n\n for (let j = 0, jl = objPos.count; j < jl; j++) {\n _v1.fromBufferAttribute(objPos, j).applyMatrix4(matrixWorld)\n\n _v2.fromBufferAttribute(objTan, j)\n\n _v2.transformDirection(matrixWorld).multiplyScalar(this.size).add(_v1)\n\n position.setXYZ(idx, _v1.x, _v1.y, _v1.z)\n\n idx = idx + 1\n\n position.setXYZ(idx, _v2.x, _v2.y, _v2.z)\n\n idx = idx + 1\n }\n\n position.needsUpdate = true\n }\n\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