created site just for chat
This commit is contained in:
1113
site/game/node_modules/three/src/objects/BatchedMesh.js
generated
vendored
Normal file
1113
site/game/node_modules/three/src/objects/BatchedMesh.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
17
site/game/node_modules/three/src/objects/Bone.js
generated
vendored
Normal file
17
site/game/node_modules/three/src/objects/Bone.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
import { Object3D } from '../core/Object3D.js';
|
||||
|
||||
class Bone extends Object3D {
|
||||
|
||||
constructor() {
|
||||
|
||||
super();
|
||||
|
||||
this.isBone = true;
|
||||
|
||||
this.type = 'Bone';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { Bone };
|
17
site/game/node_modules/three/src/objects/Group.js
generated
vendored
Normal file
17
site/game/node_modules/three/src/objects/Group.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
import { Object3D } from '../core/Object3D.js';
|
||||
|
||||
class Group extends Object3D {
|
||||
|
||||
constructor() {
|
||||
|
||||
super();
|
||||
|
||||
this.isGroup = true;
|
||||
|
||||
this.type = 'Group';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { Group };
|
277
site/game/node_modules/three/src/objects/InstancedMesh.js
generated
vendored
Normal file
277
site/game/node_modules/three/src/objects/InstancedMesh.js
generated
vendored
Normal file
@ -0,0 +1,277 @@
|
||||
import { InstancedBufferAttribute } from '../core/InstancedBufferAttribute.js';
|
||||
import { Mesh } from './Mesh.js';
|
||||
import { Box3 } from '../math/Box3.js';
|
||||
import { Matrix4 } from '../math/Matrix4.js';
|
||||
import { Sphere } from '../math/Sphere.js';
|
||||
import { DataTexture } from '../textures/DataTexture.js';
|
||||
import { FloatType, RedFormat } from '../constants.js';
|
||||
|
||||
const _instanceLocalMatrix = /*@__PURE__*/ new Matrix4();
|
||||
const _instanceWorldMatrix = /*@__PURE__*/ new Matrix4();
|
||||
|
||||
const _instanceIntersects = [];
|
||||
|
||||
const _box3 = /*@__PURE__*/ new Box3();
|
||||
const _identity = /*@__PURE__*/ new Matrix4();
|
||||
const _mesh = /*@__PURE__*/ new Mesh();
|
||||
const _sphere = /*@__PURE__*/ new Sphere();
|
||||
|
||||
class InstancedMesh extends Mesh {
|
||||
|
||||
constructor( geometry, material, count ) {
|
||||
|
||||
super( geometry, material );
|
||||
|
||||
this.isInstancedMesh = true;
|
||||
|
||||
this.instanceMatrix = new InstancedBufferAttribute( new Float32Array( count * 16 ), 16 );
|
||||
this.instanceColor = null;
|
||||
this.morphTexture = null;
|
||||
|
||||
this.count = count;
|
||||
|
||||
this.boundingBox = null;
|
||||
this.boundingSphere = null;
|
||||
|
||||
for ( let i = 0; i < count; i ++ ) {
|
||||
|
||||
this.setMatrixAt( i, _identity );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
computeBoundingBox() {
|
||||
|
||||
const geometry = this.geometry;
|
||||
const count = this.count;
|
||||
|
||||
if ( this.boundingBox === null ) {
|
||||
|
||||
this.boundingBox = new Box3();
|
||||
|
||||
}
|
||||
|
||||
if ( geometry.boundingBox === null ) {
|
||||
|
||||
geometry.computeBoundingBox();
|
||||
|
||||
}
|
||||
|
||||
this.boundingBox.makeEmpty();
|
||||
|
||||
for ( let i = 0; i < count; i ++ ) {
|
||||
|
||||
this.getMatrixAt( i, _instanceLocalMatrix );
|
||||
|
||||
_box3.copy( geometry.boundingBox ).applyMatrix4( _instanceLocalMatrix );
|
||||
|
||||
this.boundingBox.union( _box3 );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
computeBoundingSphere() {
|
||||
|
||||
const geometry = this.geometry;
|
||||
const count = this.count;
|
||||
|
||||
if ( this.boundingSphere === null ) {
|
||||
|
||||
this.boundingSphere = new Sphere();
|
||||
|
||||
}
|
||||
|
||||
if ( geometry.boundingSphere === null ) {
|
||||
|
||||
geometry.computeBoundingSphere();
|
||||
|
||||
}
|
||||
|
||||
this.boundingSphere.makeEmpty();
|
||||
|
||||
for ( let i = 0; i < count; i ++ ) {
|
||||
|
||||
this.getMatrixAt( i, _instanceLocalMatrix );
|
||||
|
||||
_sphere.copy( geometry.boundingSphere ).applyMatrix4( _instanceLocalMatrix );
|
||||
|
||||
this.boundingSphere.union( _sphere );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
copy( source, recursive ) {
|
||||
|
||||
super.copy( source, recursive );
|
||||
|
||||
this.instanceMatrix.copy( source.instanceMatrix );
|
||||
|
||||
if ( source.morphTexture !== null ) this.morphTexture = source.morphTexture.clone();
|
||||
if ( source.instanceColor !== null ) this.instanceColor = source.instanceColor.clone();
|
||||
|
||||
this.count = source.count;
|
||||
|
||||
if ( source.boundingBox !== null ) this.boundingBox = source.boundingBox.clone();
|
||||
if ( source.boundingSphere !== null ) this.boundingSphere = source.boundingSphere.clone();
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
getColorAt( index, color ) {
|
||||
|
||||
color.fromArray( this.instanceColor.array, index * 3 );
|
||||
|
||||
}
|
||||
|
||||
getMatrixAt( index, matrix ) {
|
||||
|
||||
matrix.fromArray( this.instanceMatrix.array, index * 16 );
|
||||
|
||||
}
|
||||
|
||||
getMorphAt( index, object ) {
|
||||
|
||||
const objectInfluences = object.morphTargetInfluences;
|
||||
|
||||
const array = this.morphTexture.source.data.data;
|
||||
|
||||
const len = objectInfluences.length + 1; // All influences + the baseInfluenceSum
|
||||
|
||||
const dataIndex = index * len + 1; // Skip the baseInfluenceSum at the beginning
|
||||
|
||||
for ( let i = 0; i < objectInfluences.length; i ++ ) {
|
||||
|
||||
objectInfluences[ i ] = array[ dataIndex + i ];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
raycast( raycaster, intersects ) {
|
||||
|
||||
const matrixWorld = this.matrixWorld;
|
||||
const raycastTimes = this.count;
|
||||
|
||||
_mesh.geometry = this.geometry;
|
||||
_mesh.material = this.material;
|
||||
|
||||
if ( _mesh.material === undefined ) return;
|
||||
|
||||
// test with bounding sphere first
|
||||
|
||||
if ( this.boundingSphere === null ) this.computeBoundingSphere();
|
||||
|
||||
_sphere.copy( this.boundingSphere );
|
||||
_sphere.applyMatrix4( matrixWorld );
|
||||
|
||||
if ( raycaster.ray.intersectsSphere( _sphere ) === false ) return;
|
||||
|
||||
// now test each instance
|
||||
|
||||
for ( let instanceId = 0; instanceId < raycastTimes; instanceId ++ ) {
|
||||
|
||||
// calculate the world matrix for each instance
|
||||
|
||||
this.getMatrixAt( instanceId, _instanceLocalMatrix );
|
||||
|
||||
_instanceWorldMatrix.multiplyMatrices( matrixWorld, _instanceLocalMatrix );
|
||||
|
||||
// the mesh represents this single instance
|
||||
|
||||
_mesh.matrixWorld = _instanceWorldMatrix;
|
||||
|
||||
_mesh.raycast( raycaster, _instanceIntersects );
|
||||
|
||||
// process the result of raycast
|
||||
|
||||
for ( let i = 0, l = _instanceIntersects.length; i < l; i ++ ) {
|
||||
|
||||
const intersect = _instanceIntersects[ i ];
|
||||
intersect.instanceId = instanceId;
|
||||
intersect.object = this;
|
||||
intersects.push( intersect );
|
||||
|
||||
}
|
||||
|
||||
_instanceIntersects.length = 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
setColorAt( index, color ) {
|
||||
|
||||
if ( this.instanceColor === null ) {
|
||||
|
||||
this.instanceColor = new InstancedBufferAttribute( new Float32Array( this.instanceMatrix.count * 3 ).fill( 1 ), 3 );
|
||||
|
||||
}
|
||||
|
||||
color.toArray( this.instanceColor.array, index * 3 );
|
||||
|
||||
}
|
||||
|
||||
setMatrixAt( index, matrix ) {
|
||||
|
||||
matrix.toArray( this.instanceMatrix.array, index * 16 );
|
||||
|
||||
}
|
||||
|
||||
setMorphAt( index, object ) {
|
||||
|
||||
const objectInfluences = object.morphTargetInfluences;
|
||||
|
||||
const len = objectInfluences.length + 1; // morphBaseInfluence + all influences
|
||||
|
||||
if ( this.morphTexture === null ) {
|
||||
|
||||
this.morphTexture = new DataTexture( new Float32Array( len * this.count ), len, this.count, RedFormat, FloatType );
|
||||
|
||||
}
|
||||
|
||||
const array = this.morphTexture.source.data.data;
|
||||
|
||||
let morphInfluencesSum = 0;
|
||||
|
||||
for ( let i = 0; i < objectInfluences.length; i ++ ) {
|
||||
|
||||
morphInfluencesSum += objectInfluences[ i ];
|
||||
|
||||
}
|
||||
|
||||
const morphBaseInfluence = this.geometry.morphTargetsRelative ? 1 : 1 - morphInfluencesSum;
|
||||
|
||||
const dataIndex = len * index;
|
||||
|
||||
array[ dataIndex ] = morphBaseInfluence;
|
||||
|
||||
array.set( objectInfluences, dataIndex + 1 );
|
||||
|
||||
}
|
||||
|
||||
updateMorphTargets() {
|
||||
|
||||
}
|
||||
|
||||
dispose() {
|
||||
|
||||
this.dispatchEvent( { type: 'dispose' } );
|
||||
|
||||
if ( this.morphTexture !== null ) {
|
||||
|
||||
this.morphTexture.dispose();
|
||||
this.morphTexture = null;
|
||||
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { InstancedMesh };
|
214
site/game/node_modules/three/src/objects/LOD.js
generated
vendored
Normal file
214
site/game/node_modules/three/src/objects/LOD.js
generated
vendored
Normal file
@ -0,0 +1,214 @@
|
||||
import { Vector3 } from '../math/Vector3.js';
|
||||
import { Object3D } from '../core/Object3D.js';
|
||||
|
||||
const _v1 = /*@__PURE__*/ new Vector3();
|
||||
const _v2 = /*@__PURE__*/ new Vector3();
|
||||
|
||||
class LOD extends Object3D {
|
||||
|
||||
constructor() {
|
||||
|
||||
super();
|
||||
|
||||
this._currentLevel = 0;
|
||||
|
||||
this.type = 'LOD';
|
||||
|
||||
Object.defineProperties( this, {
|
||||
levels: {
|
||||
enumerable: true,
|
||||
value: []
|
||||
},
|
||||
isLOD: {
|
||||
value: true,
|
||||
}
|
||||
} );
|
||||
|
||||
this.autoUpdate = true;
|
||||
|
||||
}
|
||||
|
||||
copy( source ) {
|
||||
|
||||
super.copy( source, false );
|
||||
|
||||
const levels = source.levels;
|
||||
|
||||
for ( let i = 0, l = levels.length; i < l; i ++ ) {
|
||||
|
||||
const level = levels[ i ];
|
||||
|
||||
this.addLevel( level.object.clone(), level.distance, level.hysteresis );
|
||||
|
||||
}
|
||||
|
||||
this.autoUpdate = source.autoUpdate;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
addLevel( object, distance = 0, hysteresis = 0 ) {
|
||||
|
||||
distance = Math.abs( distance );
|
||||
|
||||
const levels = this.levels;
|
||||
|
||||
let l;
|
||||
|
||||
for ( l = 0; l < levels.length; l ++ ) {
|
||||
|
||||
if ( distance < levels[ l ].distance ) {
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
levels.splice( l, 0, { distance: distance, hysteresis: hysteresis, object: object } );
|
||||
|
||||
this.add( object );
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
getCurrentLevel() {
|
||||
|
||||
return this._currentLevel;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
getObjectForDistance( distance ) {
|
||||
|
||||
const levels = this.levels;
|
||||
|
||||
if ( levels.length > 0 ) {
|
||||
|
||||
let i, l;
|
||||
|
||||
for ( i = 1, l = levels.length; i < l; i ++ ) {
|
||||
|
||||
let levelDistance = levels[ i ].distance;
|
||||
|
||||
if ( levels[ i ].object.visible ) {
|
||||
|
||||
levelDistance -= levelDistance * levels[ i ].hysteresis;
|
||||
|
||||
}
|
||||
|
||||
if ( distance < levelDistance ) {
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return levels[ i - 1 ].object;
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
raycast( raycaster, intersects ) {
|
||||
|
||||
const levels = this.levels;
|
||||
|
||||
if ( levels.length > 0 ) {
|
||||
|
||||
_v1.setFromMatrixPosition( this.matrixWorld );
|
||||
|
||||
const distance = raycaster.ray.origin.distanceTo( _v1 );
|
||||
|
||||
this.getObjectForDistance( distance ).raycast( raycaster, intersects );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
update( camera ) {
|
||||
|
||||
const levels = this.levels;
|
||||
|
||||
if ( levels.length > 1 ) {
|
||||
|
||||
_v1.setFromMatrixPosition( camera.matrixWorld );
|
||||
_v2.setFromMatrixPosition( this.matrixWorld );
|
||||
|
||||
const distance = _v1.distanceTo( _v2 ) / camera.zoom;
|
||||
|
||||
levels[ 0 ].object.visible = true;
|
||||
|
||||
let i, l;
|
||||
|
||||
for ( i = 1, l = levels.length; i < l; i ++ ) {
|
||||
|
||||
let levelDistance = levels[ i ].distance;
|
||||
|
||||
if ( levels[ i ].object.visible ) {
|
||||
|
||||
levelDistance -= levelDistance * levels[ i ].hysteresis;
|
||||
|
||||
}
|
||||
|
||||
if ( distance >= levelDistance ) {
|
||||
|
||||
levels[ i - 1 ].object.visible = false;
|
||||
levels[ i ].object.visible = true;
|
||||
|
||||
} else {
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this._currentLevel = i - 1;
|
||||
|
||||
for ( ; i < l; i ++ ) {
|
||||
|
||||
levels[ i ].object.visible = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
toJSON( meta ) {
|
||||
|
||||
const data = super.toJSON( meta );
|
||||
|
||||
if ( this.autoUpdate === false ) data.object.autoUpdate = false;
|
||||
|
||||
data.object.levels = [];
|
||||
|
||||
const levels = this.levels;
|
||||
|
||||
for ( let i = 0, l = levels.length; i < l; i ++ ) {
|
||||
|
||||
const level = levels[ i ];
|
||||
|
||||
data.object.levels.push( {
|
||||
object: level.object.uuid,
|
||||
distance: level.distance,
|
||||
hysteresis: level.hysteresis
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
export { LOD };
|
245
site/game/node_modules/three/src/objects/Line.js
generated
vendored
Normal file
245
site/game/node_modules/three/src/objects/Line.js
generated
vendored
Normal file
@ -0,0 +1,245 @@
|
||||
import { Sphere } from '../math/Sphere.js';
|
||||
import { Ray } from '../math/Ray.js';
|
||||
import { Matrix4 } from '../math/Matrix4.js';
|
||||
import { Object3D } from '../core/Object3D.js';
|
||||
import { Vector3 } from '../math/Vector3.js';
|
||||
import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
|
||||
import { BufferGeometry } from '../core/BufferGeometry.js';
|
||||
import { Float32BufferAttribute } from '../core/BufferAttribute.js';
|
||||
|
||||
const _vStart = /*@__PURE__*/ new Vector3();
|
||||
const _vEnd = /*@__PURE__*/ new Vector3();
|
||||
|
||||
const _inverseMatrix = /*@__PURE__*/ new Matrix4();
|
||||
const _ray = /*@__PURE__*/ new Ray();
|
||||
const _sphere = /*@__PURE__*/ new Sphere();
|
||||
|
||||
const _intersectPointOnRay = /*@__PURE__*/ new Vector3();
|
||||
const _intersectPointOnSegment = /*@__PURE__*/ new Vector3();
|
||||
|
||||
class Line extends Object3D {
|
||||
|
||||
constructor( geometry = new BufferGeometry(), material = new LineBasicMaterial() ) {
|
||||
|
||||
super();
|
||||
|
||||
this.isLine = true;
|
||||
|
||||
this.type = 'Line';
|
||||
|
||||
this.geometry = geometry;
|
||||
this.material = material;
|
||||
|
||||
this.updateMorphTargets();
|
||||
|
||||
}
|
||||
|
||||
copy( source, recursive ) {
|
||||
|
||||
super.copy( source, recursive );
|
||||
|
||||
this.material = Array.isArray( source.material ) ? source.material.slice() : source.material;
|
||||
this.geometry = source.geometry;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
computeLineDistances() {
|
||||
|
||||
const geometry = this.geometry;
|
||||
|
||||
// we assume non-indexed geometry
|
||||
|
||||
if ( geometry.index === null ) {
|
||||
|
||||
const positionAttribute = geometry.attributes.position;
|
||||
const lineDistances = [ 0 ];
|
||||
|
||||
for ( let i = 1, l = positionAttribute.count; i < l; i ++ ) {
|
||||
|
||||
_vStart.fromBufferAttribute( positionAttribute, i - 1 );
|
||||
_vEnd.fromBufferAttribute( positionAttribute, i );
|
||||
|
||||
lineDistances[ i ] = lineDistances[ i - 1 ];
|
||||
lineDistances[ i ] += _vStart.distanceTo( _vEnd );
|
||||
|
||||
}
|
||||
|
||||
geometry.setAttribute( 'lineDistance', new Float32BufferAttribute( lineDistances, 1 ) );
|
||||
|
||||
} else {
|
||||
|
||||
console.warn( 'THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.' );
|
||||
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
raycast( raycaster, intersects ) {
|
||||
|
||||
const geometry = this.geometry;
|
||||
const matrixWorld = this.matrixWorld;
|
||||
const threshold = raycaster.params.Line.threshold;
|
||||
const drawRange = geometry.drawRange;
|
||||
|
||||
// Checking boundingSphere distance to ray
|
||||
|
||||
if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
|
||||
|
||||
_sphere.copy( geometry.boundingSphere );
|
||||
_sphere.applyMatrix4( matrixWorld );
|
||||
_sphere.radius += threshold;
|
||||
|
||||
if ( raycaster.ray.intersectsSphere( _sphere ) === false ) return;
|
||||
|
||||
//
|
||||
|
||||
_inverseMatrix.copy( matrixWorld ).invert();
|
||||
_ray.copy( raycaster.ray ).applyMatrix4( _inverseMatrix );
|
||||
|
||||
const localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );
|
||||
const localThresholdSq = localThreshold * localThreshold;
|
||||
|
||||
const step = this.isLineSegments ? 2 : 1;
|
||||
|
||||
const index = geometry.index;
|
||||
const attributes = geometry.attributes;
|
||||
const positionAttribute = attributes.position;
|
||||
|
||||
if ( index !== null ) {
|
||||
|
||||
const start = Math.max( 0, drawRange.start );
|
||||
const end = Math.min( index.count, ( drawRange.start + drawRange.count ) );
|
||||
|
||||
for ( let i = start, l = end - 1; i < l; i += step ) {
|
||||
|
||||
const a = index.getX( i );
|
||||
const b = index.getX( i + 1 );
|
||||
|
||||
const intersect = checkIntersection( this, raycaster, _ray, localThresholdSq, a, b );
|
||||
|
||||
if ( intersect ) {
|
||||
|
||||
intersects.push( intersect );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( this.isLineLoop ) {
|
||||
|
||||
const a = index.getX( end - 1 );
|
||||
const b = index.getX( start );
|
||||
|
||||
const intersect = checkIntersection( this, raycaster, _ray, localThresholdSq, a, b );
|
||||
|
||||
if ( intersect ) {
|
||||
|
||||
intersects.push( intersect );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
const start = Math.max( 0, drawRange.start );
|
||||
const end = Math.min( positionAttribute.count, ( drawRange.start + drawRange.count ) );
|
||||
|
||||
for ( let i = start, l = end - 1; i < l; i += step ) {
|
||||
|
||||
const intersect = checkIntersection( this, raycaster, _ray, localThresholdSq, i, i + 1 );
|
||||
|
||||
if ( intersect ) {
|
||||
|
||||
intersects.push( intersect );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( this.isLineLoop ) {
|
||||
|
||||
const intersect = checkIntersection( this, raycaster, _ray, localThresholdSq, end - 1, start );
|
||||
|
||||
if ( intersect ) {
|
||||
|
||||
intersects.push( intersect );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
updateMorphTargets() {
|
||||
|
||||
const geometry = this.geometry;
|
||||
|
||||
const morphAttributes = geometry.morphAttributes;
|
||||
const keys = Object.keys( morphAttributes );
|
||||
|
||||
if ( keys.length > 0 ) {
|
||||
|
||||
const morphAttribute = morphAttributes[ keys[ 0 ] ];
|
||||
|
||||
if ( morphAttribute !== undefined ) {
|
||||
|
||||
this.morphTargetInfluences = [];
|
||||
this.morphTargetDictionary = {};
|
||||
|
||||
for ( let m = 0, ml = morphAttribute.length; m < ml; m ++ ) {
|
||||
|
||||
const name = morphAttribute[ m ].name || String( m );
|
||||
|
||||
this.morphTargetInfluences.push( 0 );
|
||||
this.morphTargetDictionary[ name ] = m;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function checkIntersection( object, raycaster, ray, thresholdSq, a, b ) {
|
||||
|
||||
const positionAttribute = object.geometry.attributes.position;
|
||||
|
||||
_vStart.fromBufferAttribute( positionAttribute, a );
|
||||
_vEnd.fromBufferAttribute( positionAttribute, b );
|
||||
|
||||
const distSq = ray.distanceSqToSegment( _vStart, _vEnd, _intersectPointOnRay, _intersectPointOnSegment );
|
||||
|
||||
if ( distSq > thresholdSq ) return;
|
||||
|
||||
_intersectPointOnRay.applyMatrix4( object.matrixWorld ); // Move back to world space for distance calculation
|
||||
|
||||
const distance = raycaster.ray.origin.distanceTo( _intersectPointOnRay );
|
||||
|
||||
if ( distance < raycaster.near || distance > raycaster.far ) return;
|
||||
|
||||
return {
|
||||
|
||||
distance: distance,
|
||||
// What do we want? intersection point on the ray or on the segment??
|
||||
// point: raycaster.ray.at( distance ),
|
||||
point: _intersectPointOnSegment.clone().applyMatrix4( object.matrixWorld ),
|
||||
index: a,
|
||||
face: null,
|
||||
faceIndex: null,
|
||||
object: object
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
export { Line };
|
17
site/game/node_modules/three/src/objects/LineLoop.js
generated
vendored
Normal file
17
site/game/node_modules/three/src/objects/LineLoop.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
import { Line } from './Line.js';
|
||||
|
||||
class LineLoop extends Line {
|
||||
|
||||
constructor( geometry, material ) {
|
||||
|
||||
super( geometry, material );
|
||||
|
||||
this.isLineLoop = true;
|
||||
|
||||
this.type = 'LineLoop';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { LineLoop };
|
55
site/game/node_modules/three/src/objects/LineSegments.js
generated
vendored
Normal file
55
site/game/node_modules/three/src/objects/LineSegments.js
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
import { Line } from './Line.js';
|
||||
import { Vector3 } from '../math/Vector3.js';
|
||||
import { Float32BufferAttribute } from '../core/BufferAttribute.js';
|
||||
|
||||
const _start = /*@__PURE__*/ new Vector3();
|
||||
const _end = /*@__PURE__*/ new Vector3();
|
||||
|
||||
class LineSegments extends Line {
|
||||
|
||||
constructor( geometry, material ) {
|
||||
|
||||
super( geometry, material );
|
||||
|
||||
this.isLineSegments = true;
|
||||
|
||||
this.type = 'LineSegments';
|
||||
|
||||
}
|
||||
|
||||
computeLineDistances() {
|
||||
|
||||
const geometry = this.geometry;
|
||||
|
||||
// we assume non-indexed geometry
|
||||
|
||||
if ( geometry.index === null ) {
|
||||
|
||||
const positionAttribute = geometry.attributes.position;
|
||||
const lineDistances = [];
|
||||
|
||||
for ( let i = 0, l = positionAttribute.count; i < l; i += 2 ) {
|
||||
|
||||
_start.fromBufferAttribute( positionAttribute, i );
|
||||
_end.fromBufferAttribute( positionAttribute, i + 1 );
|
||||
|
||||
lineDistances[ i ] = ( i === 0 ) ? 0 : lineDistances[ i - 1 ];
|
||||
lineDistances[ i + 1 ] = lineDistances[ i ] + _start.distanceTo( _end );
|
||||
|
||||
}
|
||||
|
||||
geometry.setAttribute( 'lineDistance', new Float32BufferAttribute( lineDistances, 1 ) );
|
||||
|
||||
} else {
|
||||
|
||||
console.warn( 'THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.' );
|
||||
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { LineSegments };
|
428
site/game/node_modules/three/src/objects/Mesh.js
generated
vendored
Normal file
428
site/game/node_modules/three/src/objects/Mesh.js
generated
vendored
Normal file
@ -0,0 +1,428 @@
|
||||
import { Vector3 } from '../math/Vector3.js';
|
||||
import { Vector2 } from '../math/Vector2.js';
|
||||
import { Sphere } from '../math/Sphere.js';
|
||||
import { Ray } from '../math/Ray.js';
|
||||
import { Matrix4 } from '../math/Matrix4.js';
|
||||
import { Object3D } from '../core/Object3D.js';
|
||||
import { Triangle } from '../math/Triangle.js';
|
||||
import { BackSide, FrontSide } from '../constants.js';
|
||||
import { MeshBasicMaterial } from '../materials/MeshBasicMaterial.js';
|
||||
import { BufferGeometry } from '../core/BufferGeometry.js';
|
||||
|
||||
const _inverseMatrix = /*@__PURE__*/ new Matrix4();
|
||||
const _ray = /*@__PURE__*/ new Ray();
|
||||
const _sphere = /*@__PURE__*/ new Sphere();
|
||||
const _sphereHitAt = /*@__PURE__*/ new Vector3();
|
||||
|
||||
const _vA = /*@__PURE__*/ new Vector3();
|
||||
const _vB = /*@__PURE__*/ new Vector3();
|
||||
const _vC = /*@__PURE__*/ new Vector3();
|
||||
|
||||
const _tempA = /*@__PURE__*/ new Vector3();
|
||||
const _morphA = /*@__PURE__*/ new Vector3();
|
||||
|
||||
const _uvA = /*@__PURE__*/ new Vector2();
|
||||
const _uvB = /*@__PURE__*/ new Vector2();
|
||||
const _uvC = /*@__PURE__*/ new Vector2();
|
||||
|
||||
const _normalA = /*@__PURE__*/ new Vector3();
|
||||
const _normalB = /*@__PURE__*/ new Vector3();
|
||||
const _normalC = /*@__PURE__*/ new Vector3();
|
||||
|
||||
const _intersectionPoint = /*@__PURE__*/ new Vector3();
|
||||
const _intersectionPointWorld = /*@__PURE__*/ new Vector3();
|
||||
|
||||
class Mesh extends Object3D {
|
||||
|
||||
constructor( geometry = new BufferGeometry(), material = new MeshBasicMaterial() ) {
|
||||
|
||||
super();
|
||||
|
||||
this.isMesh = true;
|
||||
|
||||
this.type = 'Mesh';
|
||||
|
||||
this.geometry = geometry;
|
||||
this.material = material;
|
||||
|
||||
this.updateMorphTargets();
|
||||
|
||||
}
|
||||
|
||||
copy( source, recursive ) {
|
||||
|
||||
super.copy( source, recursive );
|
||||
|
||||
if ( source.morphTargetInfluences !== undefined ) {
|
||||
|
||||
this.morphTargetInfluences = source.morphTargetInfluences.slice();
|
||||
|
||||
}
|
||||
|
||||
if ( source.morphTargetDictionary !== undefined ) {
|
||||
|
||||
this.morphTargetDictionary = Object.assign( {}, source.morphTargetDictionary );
|
||||
|
||||
}
|
||||
|
||||
this.material = Array.isArray( source.material ) ? source.material.slice() : source.material;
|
||||
this.geometry = source.geometry;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
updateMorphTargets() {
|
||||
|
||||
const geometry = this.geometry;
|
||||
|
||||
const morphAttributes = geometry.morphAttributes;
|
||||
const keys = Object.keys( morphAttributes );
|
||||
|
||||
if ( keys.length > 0 ) {
|
||||
|
||||
const morphAttribute = morphAttributes[ keys[ 0 ] ];
|
||||
|
||||
if ( morphAttribute !== undefined ) {
|
||||
|
||||
this.morphTargetInfluences = [];
|
||||
this.morphTargetDictionary = {};
|
||||
|
||||
for ( let m = 0, ml = morphAttribute.length; m < ml; m ++ ) {
|
||||
|
||||
const name = morphAttribute[ m ].name || String( m );
|
||||
|
||||
this.morphTargetInfluences.push( 0 );
|
||||
this.morphTargetDictionary[ name ] = m;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
getVertexPosition( index, target ) {
|
||||
|
||||
const geometry = this.geometry;
|
||||
const position = geometry.attributes.position;
|
||||
const morphPosition = geometry.morphAttributes.position;
|
||||
const morphTargetsRelative = geometry.morphTargetsRelative;
|
||||
|
||||
target.fromBufferAttribute( position, index );
|
||||
|
||||
const morphInfluences = this.morphTargetInfluences;
|
||||
|
||||
if ( morphPosition && morphInfluences ) {
|
||||
|
||||
_morphA.set( 0, 0, 0 );
|
||||
|
||||
for ( let i = 0, il = morphPosition.length; i < il; i ++ ) {
|
||||
|
||||
const influence = morphInfluences[ i ];
|
||||
const morphAttribute = morphPosition[ i ];
|
||||
|
||||
if ( influence === 0 ) continue;
|
||||
|
||||
_tempA.fromBufferAttribute( morphAttribute, index );
|
||||
|
||||
if ( morphTargetsRelative ) {
|
||||
|
||||
_morphA.addScaledVector( _tempA, influence );
|
||||
|
||||
} else {
|
||||
|
||||
_morphA.addScaledVector( _tempA.sub( target ), influence );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
target.add( _morphA );
|
||||
|
||||
}
|
||||
|
||||
return target;
|
||||
|
||||
}
|
||||
|
||||
raycast( raycaster, intersects ) {
|
||||
|
||||
const geometry = this.geometry;
|
||||
const material = this.material;
|
||||
const matrixWorld = this.matrixWorld;
|
||||
|
||||
if ( material === undefined ) return;
|
||||
|
||||
// test with bounding sphere in world space
|
||||
|
||||
if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
|
||||
|
||||
_sphere.copy( geometry.boundingSphere );
|
||||
_sphere.applyMatrix4( matrixWorld );
|
||||
|
||||
// check distance from ray origin to bounding sphere
|
||||
|
||||
_ray.copy( raycaster.ray ).recast( raycaster.near );
|
||||
|
||||
if ( _sphere.containsPoint( _ray.origin ) === false ) {
|
||||
|
||||
if ( _ray.intersectSphere( _sphere, _sphereHitAt ) === null ) return;
|
||||
|
||||
if ( _ray.origin.distanceToSquared( _sphereHitAt ) > ( raycaster.far - raycaster.near ) ** 2 ) return;
|
||||
|
||||
}
|
||||
|
||||
// convert ray to local space of mesh
|
||||
|
||||
_inverseMatrix.copy( matrixWorld ).invert();
|
||||
_ray.copy( raycaster.ray ).applyMatrix4( _inverseMatrix );
|
||||
|
||||
// test with bounding box in local space
|
||||
|
||||
if ( geometry.boundingBox !== null ) {
|
||||
|
||||
if ( _ray.intersectsBox( geometry.boundingBox ) === false ) return;
|
||||
|
||||
}
|
||||
|
||||
// test for intersections with geometry
|
||||
|
||||
this._computeIntersections( raycaster, intersects, _ray );
|
||||
|
||||
}
|
||||
|
||||
_computeIntersections( raycaster, intersects, rayLocalSpace ) {
|
||||
|
||||
let intersection;
|
||||
|
||||
const geometry = this.geometry;
|
||||
const material = this.material;
|
||||
|
||||
const index = geometry.index;
|
||||
const position = geometry.attributes.position;
|
||||
const uv = geometry.attributes.uv;
|
||||
const uv1 = geometry.attributes.uv1;
|
||||
const normal = geometry.attributes.normal;
|
||||
const groups = geometry.groups;
|
||||
const drawRange = geometry.drawRange;
|
||||
|
||||
if ( index !== null ) {
|
||||
|
||||
// indexed buffer geometry
|
||||
|
||||
if ( Array.isArray( material ) ) {
|
||||
|
||||
for ( let i = 0, il = groups.length; i < il; i ++ ) {
|
||||
|
||||
const group = groups[ i ];
|
||||
const groupMaterial = material[ group.materialIndex ];
|
||||
|
||||
const start = Math.max( group.start, drawRange.start );
|
||||
const end = Math.min( index.count, Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) ) );
|
||||
|
||||
for ( let j = start, jl = end; j < jl; j += 3 ) {
|
||||
|
||||
const a = index.getX( j );
|
||||
const b = index.getX( j + 1 );
|
||||
const c = index.getX( j + 2 );
|
||||
|
||||
intersection = checkGeometryIntersection( this, groupMaterial, raycaster, rayLocalSpace, uv, uv1, normal, a, b, c );
|
||||
|
||||
if ( intersection ) {
|
||||
|
||||
intersection.faceIndex = Math.floor( j / 3 ); // triangle number in indexed buffer semantics
|
||||
intersection.face.materialIndex = group.materialIndex;
|
||||
intersects.push( intersection );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
const start = Math.max( 0, drawRange.start );
|
||||
const end = Math.min( index.count, ( drawRange.start + drawRange.count ) );
|
||||
|
||||
for ( let i = start, il = end; i < il; i += 3 ) {
|
||||
|
||||
const a = index.getX( i );
|
||||
const b = index.getX( i + 1 );
|
||||
const c = index.getX( i + 2 );
|
||||
|
||||
intersection = checkGeometryIntersection( this, material, raycaster, rayLocalSpace, uv, uv1, normal, a, b, c );
|
||||
|
||||
if ( intersection ) {
|
||||
|
||||
intersection.faceIndex = Math.floor( i / 3 ); // triangle number in indexed buffer semantics
|
||||
intersects.push( intersection );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else if ( position !== undefined ) {
|
||||
|
||||
// non-indexed buffer geometry
|
||||
|
||||
if ( Array.isArray( material ) ) {
|
||||
|
||||
for ( let i = 0, il = groups.length; i < il; i ++ ) {
|
||||
|
||||
const group = groups[ i ];
|
||||
const groupMaterial = material[ group.materialIndex ];
|
||||
|
||||
const start = Math.max( group.start, drawRange.start );
|
||||
const end = Math.min( position.count, Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) ) );
|
||||
|
||||
for ( let j = start, jl = end; j < jl; j += 3 ) {
|
||||
|
||||
const a = j;
|
||||
const b = j + 1;
|
||||
const c = j + 2;
|
||||
|
||||
intersection = checkGeometryIntersection( this, groupMaterial, raycaster, rayLocalSpace, uv, uv1, normal, a, b, c );
|
||||
|
||||
if ( intersection ) {
|
||||
|
||||
intersection.faceIndex = Math.floor( j / 3 ); // triangle number in non-indexed buffer semantics
|
||||
intersection.face.materialIndex = group.materialIndex;
|
||||
intersects.push( intersection );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
const start = Math.max( 0, drawRange.start );
|
||||
const end = Math.min( position.count, ( drawRange.start + drawRange.count ) );
|
||||
|
||||
for ( let i = start, il = end; i < il; i += 3 ) {
|
||||
|
||||
const a = i;
|
||||
const b = i + 1;
|
||||
const c = i + 2;
|
||||
|
||||
intersection = checkGeometryIntersection( this, material, raycaster, rayLocalSpace, uv, uv1, normal, a, b, c );
|
||||
|
||||
if ( intersection ) {
|
||||
|
||||
intersection.faceIndex = Math.floor( i / 3 ); // triangle number in non-indexed buffer semantics
|
||||
intersects.push( intersection );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function checkIntersection( object, material, raycaster, ray, pA, pB, pC, point ) {
|
||||
|
||||
let intersect;
|
||||
|
||||
if ( material.side === BackSide ) {
|
||||
|
||||
intersect = ray.intersectTriangle( pC, pB, pA, true, point );
|
||||
|
||||
} else {
|
||||
|
||||
intersect = ray.intersectTriangle( pA, pB, pC, ( material.side === FrontSide ), point );
|
||||
|
||||
}
|
||||
|
||||
if ( intersect === null ) return null;
|
||||
|
||||
_intersectionPointWorld.copy( point );
|
||||
_intersectionPointWorld.applyMatrix4( object.matrixWorld );
|
||||
|
||||
const distance = raycaster.ray.origin.distanceTo( _intersectionPointWorld );
|
||||
|
||||
if ( distance < raycaster.near || distance > raycaster.far ) return null;
|
||||
|
||||
return {
|
||||
distance: distance,
|
||||
point: _intersectionPointWorld.clone(),
|
||||
object: object
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
function checkGeometryIntersection( object, material, raycaster, ray, uv, uv1, normal, a, b, c ) {
|
||||
|
||||
object.getVertexPosition( a, _vA );
|
||||
object.getVertexPosition( b, _vB );
|
||||
object.getVertexPosition( c, _vC );
|
||||
|
||||
const intersection = checkIntersection( object, material, raycaster, ray, _vA, _vB, _vC, _intersectionPoint );
|
||||
|
||||
if ( intersection ) {
|
||||
|
||||
if ( uv ) {
|
||||
|
||||
_uvA.fromBufferAttribute( uv, a );
|
||||
_uvB.fromBufferAttribute( uv, b );
|
||||
_uvC.fromBufferAttribute( uv, c );
|
||||
|
||||
intersection.uv = Triangle.getInterpolation( _intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2() );
|
||||
|
||||
}
|
||||
|
||||
if ( uv1 ) {
|
||||
|
||||
_uvA.fromBufferAttribute( uv1, a );
|
||||
_uvB.fromBufferAttribute( uv1, b );
|
||||
_uvC.fromBufferAttribute( uv1, c );
|
||||
|
||||
intersection.uv1 = Triangle.getInterpolation( _intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2() );
|
||||
|
||||
}
|
||||
|
||||
if ( normal ) {
|
||||
|
||||
_normalA.fromBufferAttribute( normal, a );
|
||||
_normalB.fromBufferAttribute( normal, b );
|
||||
_normalC.fromBufferAttribute( normal, c );
|
||||
|
||||
intersection.normal = Triangle.getInterpolation( _intersectionPoint, _vA, _vB, _vC, _normalA, _normalB, _normalC, new Vector3() );
|
||||
|
||||
if ( intersection.normal.dot( ray.direction ) > 0 ) {
|
||||
|
||||
intersection.normal.multiplyScalar( - 1 );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const face = {
|
||||
a: a,
|
||||
b: b,
|
||||
c: c,
|
||||
normal: new Vector3(),
|
||||
materialIndex: 0
|
||||
};
|
||||
|
||||
Triangle.getNormal( _vA, _vB, _vC, face.normal );
|
||||
|
||||
intersection.face = face;
|
||||
|
||||
}
|
||||
|
||||
return intersection;
|
||||
|
||||
}
|
||||
|
||||
export { Mesh };
|
166
site/game/node_modules/three/src/objects/Points.js
generated
vendored
Normal file
166
site/game/node_modules/three/src/objects/Points.js
generated
vendored
Normal file
@ -0,0 +1,166 @@
|
||||
import { Sphere } from '../math/Sphere.js';
|
||||
import { Ray } from '../math/Ray.js';
|
||||
import { Matrix4 } from '../math/Matrix4.js';
|
||||
import { Object3D } from '../core/Object3D.js';
|
||||
import { Vector3 } from '../math/Vector3.js';
|
||||
import { PointsMaterial } from '../materials/PointsMaterial.js';
|
||||
import { BufferGeometry } from '../core/BufferGeometry.js';
|
||||
|
||||
const _inverseMatrix = /*@__PURE__*/ new Matrix4();
|
||||
const _ray = /*@__PURE__*/ new Ray();
|
||||
const _sphere = /*@__PURE__*/ new Sphere();
|
||||
const _position = /*@__PURE__*/ new Vector3();
|
||||
|
||||
class Points extends Object3D {
|
||||
|
||||
constructor( geometry = new BufferGeometry(), material = new PointsMaterial() ) {
|
||||
|
||||
super();
|
||||
|
||||
this.isPoints = true;
|
||||
|
||||
this.type = 'Points';
|
||||
|
||||
this.geometry = geometry;
|
||||
this.material = material;
|
||||
|
||||
this.updateMorphTargets();
|
||||
|
||||
}
|
||||
|
||||
copy( source, recursive ) {
|
||||
|
||||
super.copy( source, recursive );
|
||||
|
||||
this.material = Array.isArray( source.material ) ? source.material.slice() : source.material;
|
||||
this.geometry = source.geometry;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
raycast( raycaster, intersects ) {
|
||||
|
||||
const geometry = this.geometry;
|
||||
const matrixWorld = this.matrixWorld;
|
||||
const threshold = raycaster.params.Points.threshold;
|
||||
const drawRange = geometry.drawRange;
|
||||
|
||||
// Checking boundingSphere distance to ray
|
||||
|
||||
if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
|
||||
|
||||
_sphere.copy( geometry.boundingSphere );
|
||||
_sphere.applyMatrix4( matrixWorld );
|
||||
_sphere.radius += threshold;
|
||||
|
||||
if ( raycaster.ray.intersectsSphere( _sphere ) === false ) return;
|
||||
|
||||
//
|
||||
|
||||
_inverseMatrix.copy( matrixWorld ).invert();
|
||||
_ray.copy( raycaster.ray ).applyMatrix4( _inverseMatrix );
|
||||
|
||||
const localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );
|
||||
const localThresholdSq = localThreshold * localThreshold;
|
||||
|
||||
const index = geometry.index;
|
||||
const attributes = geometry.attributes;
|
||||
const positionAttribute = attributes.position;
|
||||
|
||||
if ( index !== null ) {
|
||||
|
||||
const start = Math.max( 0, drawRange.start );
|
||||
const end = Math.min( index.count, ( drawRange.start + drawRange.count ) );
|
||||
|
||||
for ( let i = start, il = end; i < il; i ++ ) {
|
||||
|
||||
const a = index.getX( i );
|
||||
|
||||
_position.fromBufferAttribute( positionAttribute, a );
|
||||
|
||||
testPoint( _position, a, localThresholdSq, matrixWorld, raycaster, intersects, this );
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
const start = Math.max( 0, drawRange.start );
|
||||
const end = Math.min( positionAttribute.count, ( drawRange.start + drawRange.count ) );
|
||||
|
||||
for ( let i = start, l = end; i < l; i ++ ) {
|
||||
|
||||
_position.fromBufferAttribute( positionAttribute, i );
|
||||
|
||||
testPoint( _position, i, localThresholdSq, matrixWorld, raycaster, intersects, this );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
updateMorphTargets() {
|
||||
|
||||
const geometry = this.geometry;
|
||||
|
||||
const morphAttributes = geometry.morphAttributes;
|
||||
const keys = Object.keys( morphAttributes );
|
||||
|
||||
if ( keys.length > 0 ) {
|
||||
|
||||
const morphAttribute = morphAttributes[ keys[ 0 ] ];
|
||||
|
||||
if ( morphAttribute !== undefined ) {
|
||||
|
||||
this.morphTargetInfluences = [];
|
||||
this.morphTargetDictionary = {};
|
||||
|
||||
for ( let m = 0, ml = morphAttribute.length; m < ml; m ++ ) {
|
||||
|
||||
const name = morphAttribute[ m ].name || String( m );
|
||||
|
||||
this.morphTargetInfluences.push( 0 );
|
||||
this.morphTargetDictionary[ name ] = m;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function testPoint( point, index, localThresholdSq, matrixWorld, raycaster, intersects, object ) {
|
||||
|
||||
const rayPointDistanceSq = _ray.distanceSqToPoint( point );
|
||||
|
||||
if ( rayPointDistanceSq < localThresholdSq ) {
|
||||
|
||||
const intersectPoint = new Vector3();
|
||||
|
||||
_ray.closestPointToPoint( point, intersectPoint );
|
||||
intersectPoint.applyMatrix4( matrixWorld );
|
||||
|
||||
const distance = raycaster.ray.origin.distanceTo( intersectPoint );
|
||||
|
||||
if ( distance < raycaster.near || distance > raycaster.far ) return;
|
||||
|
||||
intersects.push( {
|
||||
|
||||
distance: distance,
|
||||
distanceToRay: Math.sqrt( rayPointDistanceSq ),
|
||||
point: intersectPoint,
|
||||
index: index,
|
||||
face: null,
|
||||
object: object
|
||||
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { Points };
|
277
site/game/node_modules/three/src/objects/Skeleton.js
generated
vendored
Normal file
277
site/game/node_modules/three/src/objects/Skeleton.js
generated
vendored
Normal file
@ -0,0 +1,277 @@
|
||||
import {
|
||||
RGBAFormat,
|
||||
FloatType
|
||||
} from '../constants.js';
|
||||
import { Bone } from './Bone.js';
|
||||
import { Matrix4 } from '../math/Matrix4.js';
|
||||
import { DataTexture } from '../textures/DataTexture.js';
|
||||
import * as MathUtils from '../math/MathUtils.js';
|
||||
|
||||
const _offsetMatrix = /*@__PURE__*/ new Matrix4();
|
||||
const _identityMatrix = /*@__PURE__*/ new Matrix4();
|
||||
|
||||
class Skeleton {
|
||||
|
||||
constructor( bones = [], boneInverses = [] ) {
|
||||
|
||||
this.uuid = MathUtils.generateUUID();
|
||||
|
||||
this.bones = bones.slice( 0 );
|
||||
this.boneInverses = boneInverses;
|
||||
this.boneMatrices = null;
|
||||
|
||||
this.boneTexture = null;
|
||||
|
||||
this.init();
|
||||
|
||||
}
|
||||
|
||||
init() {
|
||||
|
||||
const bones = this.bones;
|
||||
const boneInverses = this.boneInverses;
|
||||
|
||||
this.boneMatrices = new Float32Array( bones.length * 16 );
|
||||
|
||||
// calculate inverse bone matrices if necessary
|
||||
|
||||
if ( boneInverses.length === 0 ) {
|
||||
|
||||
this.calculateInverses();
|
||||
|
||||
} else {
|
||||
|
||||
// handle special case
|
||||
|
||||
if ( bones.length !== boneInverses.length ) {
|
||||
|
||||
console.warn( 'THREE.Skeleton: Number of inverse bone matrices does not match amount of bones.' );
|
||||
|
||||
this.boneInverses = [];
|
||||
|
||||
for ( let i = 0, il = this.bones.length; i < il; i ++ ) {
|
||||
|
||||
this.boneInverses.push( new Matrix4() );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
calculateInverses() {
|
||||
|
||||
this.boneInverses.length = 0;
|
||||
|
||||
for ( let i = 0, il = this.bones.length; i < il; i ++ ) {
|
||||
|
||||
const inverse = new Matrix4();
|
||||
|
||||
if ( this.bones[ i ] ) {
|
||||
|
||||
inverse.copy( this.bones[ i ].matrixWorld ).invert();
|
||||
|
||||
}
|
||||
|
||||
this.boneInverses.push( inverse );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pose() {
|
||||
|
||||
// recover the bind-time world matrices
|
||||
|
||||
for ( let i = 0, il = this.bones.length; i < il; i ++ ) {
|
||||
|
||||
const bone = this.bones[ i ];
|
||||
|
||||
if ( bone ) {
|
||||
|
||||
bone.matrixWorld.copy( this.boneInverses[ i ] ).invert();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// compute the local matrices, positions, rotations and scales
|
||||
|
||||
for ( let i = 0, il = this.bones.length; i < il; i ++ ) {
|
||||
|
||||
const bone = this.bones[ i ];
|
||||
|
||||
if ( bone ) {
|
||||
|
||||
if ( bone.parent && bone.parent.isBone ) {
|
||||
|
||||
bone.matrix.copy( bone.parent.matrixWorld ).invert();
|
||||
bone.matrix.multiply( bone.matrixWorld );
|
||||
|
||||
} else {
|
||||
|
||||
bone.matrix.copy( bone.matrixWorld );
|
||||
|
||||
}
|
||||
|
||||
bone.matrix.decompose( bone.position, bone.quaternion, bone.scale );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
update() {
|
||||
|
||||
const bones = this.bones;
|
||||
const boneInverses = this.boneInverses;
|
||||
const boneMatrices = this.boneMatrices;
|
||||
const boneTexture = this.boneTexture;
|
||||
|
||||
// flatten bone matrices to array
|
||||
|
||||
for ( let i = 0, il = bones.length; i < il; i ++ ) {
|
||||
|
||||
// compute the offset between the current and the original transform
|
||||
|
||||
const matrix = bones[ i ] ? bones[ i ].matrixWorld : _identityMatrix;
|
||||
|
||||
_offsetMatrix.multiplyMatrices( matrix, boneInverses[ i ] );
|
||||
_offsetMatrix.toArray( boneMatrices, i * 16 );
|
||||
|
||||
}
|
||||
|
||||
if ( boneTexture !== null ) {
|
||||
|
||||
boneTexture.needsUpdate = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
clone() {
|
||||
|
||||
return new Skeleton( this.bones, this.boneInverses );
|
||||
|
||||
}
|
||||
|
||||
computeBoneTexture() {
|
||||
|
||||
// layout (1 matrix = 4 pixels)
|
||||
// RGBA RGBA RGBA RGBA (=> column1, column2, column3, column4)
|
||||
// with 8x8 pixel texture max 16 bones * 4 pixels = (8 * 8)
|
||||
// 16x16 pixel texture max 64 bones * 4 pixels = (16 * 16)
|
||||
// 32x32 pixel texture max 256 bones * 4 pixels = (32 * 32)
|
||||
// 64x64 pixel texture max 1024 bones * 4 pixels = (64 * 64)
|
||||
|
||||
let size = Math.sqrt( this.bones.length * 4 ); // 4 pixels needed for 1 matrix
|
||||
size = Math.ceil( size / 4 ) * 4;
|
||||
size = Math.max( size, 4 );
|
||||
|
||||
const boneMatrices = new Float32Array( size * size * 4 ); // 4 floats per RGBA pixel
|
||||
boneMatrices.set( this.boneMatrices ); // copy current values
|
||||
|
||||
const boneTexture = new DataTexture( boneMatrices, size, size, RGBAFormat, FloatType );
|
||||
boneTexture.needsUpdate = true;
|
||||
|
||||
this.boneMatrices = boneMatrices;
|
||||
this.boneTexture = boneTexture;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
getBoneByName( name ) {
|
||||
|
||||
for ( let i = 0, il = this.bones.length; i < il; i ++ ) {
|
||||
|
||||
const bone = this.bones[ i ];
|
||||
|
||||
if ( bone.name === name ) {
|
||||
|
||||
return bone;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return undefined;
|
||||
|
||||
}
|
||||
|
||||
dispose( ) {
|
||||
|
||||
if ( this.boneTexture !== null ) {
|
||||
|
||||
this.boneTexture.dispose();
|
||||
|
||||
this.boneTexture = null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fromJSON( json, bones ) {
|
||||
|
||||
this.uuid = json.uuid;
|
||||
|
||||
for ( let i = 0, l = json.bones.length; i < l; i ++ ) {
|
||||
|
||||
const uuid = json.bones[ i ];
|
||||
let bone = bones[ uuid ];
|
||||
|
||||
if ( bone === undefined ) {
|
||||
|
||||
console.warn( 'THREE.Skeleton: No bone found with UUID:', uuid );
|
||||
bone = new Bone();
|
||||
|
||||
}
|
||||
|
||||
this.bones.push( bone );
|
||||
this.boneInverses.push( new Matrix4().fromArray( json.boneInverses[ i ] ) );
|
||||
|
||||
}
|
||||
|
||||
this.init();
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
|
||||
const data = {
|
||||
metadata: {
|
||||
version: 4.6,
|
||||
type: 'Skeleton',
|
||||
generator: 'Skeleton.toJSON'
|
||||
},
|
||||
bones: [],
|
||||
boneInverses: []
|
||||
};
|
||||
|
||||
data.uuid = this.uuid;
|
||||
|
||||
const bones = this.bones;
|
||||
const boneInverses = this.boneInverses;
|
||||
|
||||
for ( let i = 0, l = bones.length; i < l; i ++ ) {
|
||||
|
||||
const bone = bones[ i ];
|
||||
data.bones.push( bone.uuid );
|
||||
|
||||
const boneInverse = boneInverses[ i ];
|
||||
data.boneInverses.push( boneInverse.toArray() );
|
||||
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { Skeleton };
|
257
site/game/node_modules/three/src/objects/SkinnedMesh.js
generated
vendored
Normal file
257
site/game/node_modules/three/src/objects/SkinnedMesh.js
generated
vendored
Normal file
@ -0,0 +1,257 @@
|
||||
import { Mesh } from './Mesh.js';
|
||||
import { Box3 } from '../math/Box3.js';
|
||||
import { Matrix4 } from '../math/Matrix4.js';
|
||||
import { Sphere } from '../math/Sphere.js';
|
||||
import { Vector3 } from '../math/Vector3.js';
|
||||
import { Vector4 } from '../math/Vector4.js';
|
||||
import { Ray } from '../math/Ray.js';
|
||||
import { AttachedBindMode, DetachedBindMode } from '../constants.js';
|
||||
|
||||
const _basePosition = /*@__PURE__*/ new Vector3();
|
||||
|
||||
const _skinIndex = /*@__PURE__*/ new Vector4();
|
||||
const _skinWeight = /*@__PURE__*/ new Vector4();
|
||||
|
||||
const _vector3 = /*@__PURE__*/ new Vector3();
|
||||
const _matrix4 = /*@__PURE__*/ new Matrix4();
|
||||
const _vertex = /*@__PURE__*/ new Vector3();
|
||||
|
||||
const _sphere = /*@__PURE__*/ new Sphere();
|
||||
const _inverseMatrix = /*@__PURE__*/ new Matrix4();
|
||||
const _ray = /*@__PURE__*/ new Ray();
|
||||
|
||||
class SkinnedMesh extends Mesh {
|
||||
|
||||
constructor( geometry, material ) {
|
||||
|
||||
super( geometry, material );
|
||||
|
||||
this.isSkinnedMesh = true;
|
||||
|
||||
this.type = 'SkinnedMesh';
|
||||
|
||||
this.bindMode = AttachedBindMode;
|
||||
this.bindMatrix = new Matrix4();
|
||||
this.bindMatrixInverse = new Matrix4();
|
||||
|
||||
this.boundingBox = null;
|
||||
this.boundingSphere = null;
|
||||
|
||||
}
|
||||
|
||||
computeBoundingBox() {
|
||||
|
||||
const geometry = this.geometry;
|
||||
|
||||
if ( this.boundingBox === null ) {
|
||||
|
||||
this.boundingBox = new Box3();
|
||||
|
||||
}
|
||||
|
||||
this.boundingBox.makeEmpty();
|
||||
|
||||
const positionAttribute = geometry.getAttribute( 'position' );
|
||||
|
||||
for ( let i = 0; i < positionAttribute.count; i ++ ) {
|
||||
|
||||
this.getVertexPosition( i, _vertex );
|
||||
this.boundingBox.expandByPoint( _vertex );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
computeBoundingSphere() {
|
||||
|
||||
const geometry = this.geometry;
|
||||
|
||||
if ( this.boundingSphere === null ) {
|
||||
|
||||
this.boundingSphere = new Sphere();
|
||||
|
||||
}
|
||||
|
||||
this.boundingSphere.makeEmpty();
|
||||
|
||||
const positionAttribute = geometry.getAttribute( 'position' );
|
||||
|
||||
for ( let i = 0; i < positionAttribute.count; i ++ ) {
|
||||
|
||||
this.getVertexPosition( i, _vertex );
|
||||
this.boundingSphere.expandByPoint( _vertex );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
copy( source, recursive ) {
|
||||
|
||||
super.copy( source, recursive );
|
||||
|
||||
this.bindMode = source.bindMode;
|
||||
this.bindMatrix.copy( source.bindMatrix );
|
||||
this.bindMatrixInverse.copy( source.bindMatrixInverse );
|
||||
|
||||
this.skeleton = source.skeleton;
|
||||
|
||||
if ( source.boundingBox !== null ) this.boundingBox = source.boundingBox.clone();
|
||||
if ( source.boundingSphere !== null ) this.boundingSphere = source.boundingSphere.clone();
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
raycast( raycaster, intersects ) {
|
||||
|
||||
const material = this.material;
|
||||
const matrixWorld = this.matrixWorld;
|
||||
|
||||
if ( material === undefined ) return;
|
||||
|
||||
// test with bounding sphere in world space
|
||||
|
||||
if ( this.boundingSphere === null ) this.computeBoundingSphere();
|
||||
|
||||
_sphere.copy( this.boundingSphere );
|
||||
_sphere.applyMatrix4( matrixWorld );
|
||||
|
||||
if ( raycaster.ray.intersectsSphere( _sphere ) === false ) return;
|
||||
|
||||
// convert ray to local space of skinned mesh
|
||||
|
||||
_inverseMatrix.copy( matrixWorld ).invert();
|
||||
_ray.copy( raycaster.ray ).applyMatrix4( _inverseMatrix );
|
||||
|
||||
// test with bounding box in local space
|
||||
|
||||
if ( this.boundingBox !== null ) {
|
||||
|
||||
if ( _ray.intersectsBox( this.boundingBox ) === false ) return;
|
||||
|
||||
}
|
||||
|
||||
// test for intersections with geometry
|
||||
|
||||
this._computeIntersections( raycaster, intersects, _ray );
|
||||
|
||||
}
|
||||
|
||||
getVertexPosition( index, target ) {
|
||||
|
||||
super.getVertexPosition( index, target );
|
||||
|
||||
this.applyBoneTransform( index, target );
|
||||
|
||||
return target;
|
||||
|
||||
}
|
||||
|
||||
bind( skeleton, bindMatrix ) {
|
||||
|
||||
this.skeleton = skeleton;
|
||||
|
||||
if ( bindMatrix === undefined ) {
|
||||
|
||||
this.updateMatrixWorld( true );
|
||||
|
||||
this.skeleton.calculateInverses();
|
||||
|
||||
bindMatrix = this.matrixWorld;
|
||||
|
||||
}
|
||||
|
||||
this.bindMatrix.copy( bindMatrix );
|
||||
this.bindMatrixInverse.copy( bindMatrix ).invert();
|
||||
|
||||
}
|
||||
|
||||
pose() {
|
||||
|
||||
this.skeleton.pose();
|
||||
|
||||
}
|
||||
|
||||
normalizeSkinWeights() {
|
||||
|
||||
const vector = new Vector4();
|
||||
|
||||
const skinWeight = this.geometry.attributes.skinWeight;
|
||||
|
||||
for ( let i = 0, l = skinWeight.count; i < l; i ++ ) {
|
||||
|
||||
vector.fromBufferAttribute( skinWeight, i );
|
||||
|
||||
const scale = 1.0 / vector.manhattanLength();
|
||||
|
||||
if ( scale !== Infinity ) {
|
||||
|
||||
vector.multiplyScalar( scale );
|
||||
|
||||
} else {
|
||||
|
||||
vector.set( 1, 0, 0, 0 ); // do something reasonable
|
||||
|
||||
}
|
||||
|
||||
skinWeight.setXYZW( i, vector.x, vector.y, vector.z, vector.w );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
updateMatrixWorld( force ) {
|
||||
|
||||
super.updateMatrixWorld( force );
|
||||
|
||||
if ( this.bindMode === AttachedBindMode ) {
|
||||
|
||||
this.bindMatrixInverse.copy( this.matrixWorld ).invert();
|
||||
|
||||
} else if ( this.bindMode === DetachedBindMode ) {
|
||||
|
||||
this.bindMatrixInverse.copy( this.bindMatrix ).invert();
|
||||
|
||||
} else {
|
||||
|
||||
console.warn( 'THREE.SkinnedMesh: Unrecognized bindMode: ' + this.bindMode );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
applyBoneTransform( index, vector ) {
|
||||
|
||||
const skeleton = this.skeleton;
|
||||
const geometry = this.geometry;
|
||||
|
||||
_skinIndex.fromBufferAttribute( geometry.attributes.skinIndex, index );
|
||||
_skinWeight.fromBufferAttribute( geometry.attributes.skinWeight, index );
|
||||
|
||||
_basePosition.copy( vector ).applyMatrix4( this.bindMatrix );
|
||||
|
||||
vector.set( 0, 0, 0 );
|
||||
|
||||
for ( let i = 0; i < 4; i ++ ) {
|
||||
|
||||
const weight = _skinWeight.getComponent( i );
|
||||
|
||||
if ( weight !== 0 ) {
|
||||
|
||||
const boneIndex = _skinIndex.getComponent( i );
|
||||
|
||||
_matrix4.multiplyMatrices( skeleton.bones[ boneIndex ].matrixWorld, skeleton.boneInverses[ boneIndex ] );
|
||||
|
||||
vector.addScaledVector( _vector3.copy( _basePosition ).applyMatrix4( _matrix4 ), weight );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return vector.applyMatrix4( this.bindMatrixInverse );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { SkinnedMesh };
|
181
site/game/node_modules/three/src/objects/Sprite.js
generated
vendored
Normal file
181
site/game/node_modules/three/src/objects/Sprite.js
generated
vendored
Normal file
@ -0,0 +1,181 @@
|
||||
import { Vector2 } from '../math/Vector2.js';
|
||||
import { Vector3 } from '../math/Vector3.js';
|
||||
import { Matrix4 } from '../math/Matrix4.js';
|
||||
import { Triangle } from '../math/Triangle.js';
|
||||
import { Object3D } from '../core/Object3D.js';
|
||||
import { BufferGeometry } from '../core/BufferGeometry.js';
|
||||
import { InterleavedBuffer } from '../core/InterleavedBuffer.js';
|
||||
import { InterleavedBufferAttribute } from '../core/InterleavedBufferAttribute.js';
|
||||
import { SpriteMaterial } from '../materials/SpriteMaterial.js';
|
||||
|
||||
let _geometry;
|
||||
|
||||
const _intersectPoint = /*@__PURE__*/ new Vector3();
|
||||
const _worldScale = /*@__PURE__*/ new Vector3();
|
||||
const _mvPosition = /*@__PURE__*/ new Vector3();
|
||||
|
||||
const _alignedPosition = /*@__PURE__*/ new Vector2();
|
||||
const _rotatedPosition = /*@__PURE__*/ new Vector2();
|
||||
const _viewWorldMatrix = /*@__PURE__*/ new Matrix4();
|
||||
|
||||
const _vA = /*@__PURE__*/ new Vector3();
|
||||
const _vB = /*@__PURE__*/ new Vector3();
|
||||
const _vC = /*@__PURE__*/ new Vector3();
|
||||
|
||||
const _uvA = /*@__PURE__*/ new Vector2();
|
||||
const _uvB = /*@__PURE__*/ new Vector2();
|
||||
const _uvC = /*@__PURE__*/ new Vector2();
|
||||
|
||||
class Sprite extends Object3D {
|
||||
|
||||
constructor( material = new SpriteMaterial() ) {
|
||||
|
||||
super();
|
||||
|
||||
this.isSprite = true;
|
||||
|
||||
this.type = 'Sprite';
|
||||
|
||||
if ( _geometry === undefined ) {
|
||||
|
||||
_geometry = new BufferGeometry();
|
||||
|
||||
const float32Array = new Float32Array( [
|
||||
- 0.5, - 0.5, 0, 0, 0,
|
||||
0.5, - 0.5, 0, 1, 0,
|
||||
0.5, 0.5, 0, 1, 1,
|
||||
- 0.5, 0.5, 0, 0, 1
|
||||
] );
|
||||
|
||||
const interleavedBuffer = new InterleavedBuffer( float32Array, 5 );
|
||||
|
||||
_geometry.setIndex( [ 0, 1, 2, 0, 2, 3 ] );
|
||||
_geometry.setAttribute( 'position', new InterleavedBufferAttribute( interleavedBuffer, 3, 0, false ) );
|
||||
_geometry.setAttribute( 'uv', new InterleavedBufferAttribute( interleavedBuffer, 2, 3, false ) );
|
||||
|
||||
}
|
||||
|
||||
this.geometry = _geometry;
|
||||
this.material = material;
|
||||
|
||||
this.center = new Vector2( 0.5, 0.5 );
|
||||
|
||||
}
|
||||
|
||||
raycast( raycaster, intersects ) {
|
||||
|
||||
if ( raycaster.camera === null ) {
|
||||
|
||||
console.error( 'THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.' );
|
||||
|
||||
}
|
||||
|
||||
_worldScale.setFromMatrixScale( this.matrixWorld );
|
||||
|
||||
_viewWorldMatrix.copy( raycaster.camera.matrixWorld );
|
||||
this.modelViewMatrix.multiplyMatrices( raycaster.camera.matrixWorldInverse, this.matrixWorld );
|
||||
|
||||
_mvPosition.setFromMatrixPosition( this.modelViewMatrix );
|
||||
|
||||
if ( raycaster.camera.isPerspectiveCamera && this.material.sizeAttenuation === false ) {
|
||||
|
||||
_worldScale.multiplyScalar( - _mvPosition.z );
|
||||
|
||||
}
|
||||
|
||||
const rotation = this.material.rotation;
|
||||
let sin, cos;
|
||||
|
||||
if ( rotation !== 0 ) {
|
||||
|
||||
cos = Math.cos( rotation );
|
||||
sin = Math.sin( rotation );
|
||||
|
||||
}
|
||||
|
||||
const center = this.center;
|
||||
|
||||
transformVertex( _vA.set( - 0.5, - 0.5, 0 ), _mvPosition, center, _worldScale, sin, cos );
|
||||
transformVertex( _vB.set( 0.5, - 0.5, 0 ), _mvPosition, center, _worldScale, sin, cos );
|
||||
transformVertex( _vC.set( 0.5, 0.5, 0 ), _mvPosition, center, _worldScale, sin, cos );
|
||||
|
||||
_uvA.set( 0, 0 );
|
||||
_uvB.set( 1, 0 );
|
||||
_uvC.set( 1, 1 );
|
||||
|
||||
// check first triangle
|
||||
let intersect = raycaster.ray.intersectTriangle( _vA, _vB, _vC, false, _intersectPoint );
|
||||
|
||||
if ( intersect === null ) {
|
||||
|
||||
// check second triangle
|
||||
transformVertex( _vB.set( - 0.5, 0.5, 0 ), _mvPosition, center, _worldScale, sin, cos );
|
||||
_uvB.set( 0, 1 );
|
||||
|
||||
intersect = raycaster.ray.intersectTriangle( _vA, _vC, _vB, false, _intersectPoint );
|
||||
if ( intersect === null ) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const distance = raycaster.ray.origin.distanceTo( _intersectPoint );
|
||||
|
||||
if ( distance < raycaster.near || distance > raycaster.far ) return;
|
||||
|
||||
intersects.push( {
|
||||
|
||||
distance: distance,
|
||||
point: _intersectPoint.clone(),
|
||||
uv: Triangle.getInterpolation( _intersectPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2() ),
|
||||
face: null,
|
||||
object: this
|
||||
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
copy( source, recursive ) {
|
||||
|
||||
super.copy( source, recursive );
|
||||
|
||||
if ( source.center !== undefined ) this.center.copy( source.center );
|
||||
|
||||
this.material = source.material;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function transformVertex( vertexPosition, mvPosition, center, scale, sin, cos ) {
|
||||
|
||||
// compute position in camera space
|
||||
_alignedPosition.subVectors( vertexPosition, center ).addScalar( 0.5 ).multiply( scale );
|
||||
|
||||
// to check if rotation is not zero
|
||||
if ( sin !== undefined ) {
|
||||
|
||||
_rotatedPosition.x = ( cos * _alignedPosition.x ) - ( sin * _alignedPosition.y );
|
||||
_rotatedPosition.y = ( sin * _alignedPosition.x ) + ( cos * _alignedPosition.y );
|
||||
|
||||
} else {
|
||||
|
||||
_rotatedPosition.copy( _alignedPosition );
|
||||
|
||||
}
|
||||
|
||||
|
||||
vertexPosition.copy( mvPosition );
|
||||
vertexPosition.x += _rotatedPosition.x;
|
||||
vertexPosition.y += _rotatedPosition.y;
|
||||
|
||||
// transform to world space
|
||||
vertexPosition.applyMatrix4( _viewWorldMatrix );
|
||||
|
||||
}
|
||||
|
||||
export { Sprite };
|
Reference in New Issue
Block a user