created site just for chat
This commit is contained in:
114
site/game/node_modules/three/src/helpers/ArrowHelper.js
generated
vendored
Normal file
114
site/game/node_modules/three/src/helpers/ArrowHelper.js
generated
vendored
Normal file
@ -0,0 +1,114 @@
|
||||
import { Float32BufferAttribute } from '../core/BufferAttribute.js';
|
||||
import { BufferGeometry } from '../core/BufferGeometry.js';
|
||||
import { Object3D } from '../core/Object3D.js';
|
||||
import { CylinderGeometry } from '../geometries/CylinderGeometry.js';
|
||||
import { MeshBasicMaterial } from '../materials/MeshBasicMaterial.js';
|
||||
import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
|
||||
import { Mesh } from '../objects/Mesh.js';
|
||||
import { Line } from '../objects/Line.js';
|
||||
import { Vector3 } from '../math/Vector3.js';
|
||||
|
||||
const _axis = /*@__PURE__*/ new Vector3();
|
||||
let _lineGeometry, _coneGeometry;
|
||||
|
||||
class ArrowHelper extends Object3D {
|
||||
|
||||
// dir is assumed to be normalized
|
||||
|
||||
constructor( dir = new Vector3( 0, 0, 1 ), origin = new Vector3( 0, 0, 0 ), length = 1, color = 0xffff00, headLength = length * 0.2, headWidth = headLength * 0.2 ) {
|
||||
|
||||
super();
|
||||
|
||||
this.type = 'ArrowHelper';
|
||||
|
||||
if ( _lineGeometry === undefined ) {
|
||||
|
||||
_lineGeometry = new BufferGeometry();
|
||||
_lineGeometry.setAttribute( 'position', new Float32BufferAttribute( [ 0, 0, 0, 0, 1, 0 ], 3 ) );
|
||||
|
||||
_coneGeometry = new CylinderGeometry( 0, 0.5, 1, 5, 1 );
|
||||
_coneGeometry.translate( 0, - 0.5, 0 );
|
||||
|
||||
}
|
||||
|
||||
this.position.copy( origin );
|
||||
|
||||
this.line = new Line( _lineGeometry, new LineBasicMaterial( { color: color, toneMapped: false } ) );
|
||||
this.line.matrixAutoUpdate = false;
|
||||
this.add( this.line );
|
||||
|
||||
this.cone = new Mesh( _coneGeometry, new MeshBasicMaterial( { color: color, toneMapped: false } ) );
|
||||
this.cone.matrixAutoUpdate = false;
|
||||
this.add( this.cone );
|
||||
|
||||
this.setDirection( dir );
|
||||
this.setLength( length, headLength, headWidth );
|
||||
|
||||
}
|
||||
|
||||
setDirection( dir ) {
|
||||
|
||||
// dir is assumed to be normalized
|
||||
|
||||
if ( dir.y > 0.99999 ) {
|
||||
|
||||
this.quaternion.set( 0, 0, 0, 1 );
|
||||
|
||||
} else if ( dir.y < - 0.99999 ) {
|
||||
|
||||
this.quaternion.set( 1, 0, 0, 0 );
|
||||
|
||||
} else {
|
||||
|
||||
_axis.set( dir.z, 0, - dir.x ).normalize();
|
||||
|
||||
const radians = Math.acos( dir.y );
|
||||
|
||||
this.quaternion.setFromAxisAngle( _axis, radians );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
setLength( length, headLength = length * 0.2, headWidth = headLength * 0.2 ) {
|
||||
|
||||
this.line.scale.set( 1, Math.max( 0.0001, length - headLength ), 1 ); // see #17458
|
||||
this.line.updateMatrix();
|
||||
|
||||
this.cone.scale.set( headWidth, headLength, headWidth );
|
||||
this.cone.position.y = length;
|
||||
this.cone.updateMatrix();
|
||||
|
||||
}
|
||||
|
||||
setColor( color ) {
|
||||
|
||||
this.line.material.color.set( color );
|
||||
this.cone.material.color.set( color );
|
||||
|
||||
}
|
||||
|
||||
copy( source ) {
|
||||
|
||||
super.copy( source, false );
|
||||
|
||||
this.line.copy( source.line );
|
||||
this.cone.copy( source.cone );
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
dispose() {
|
||||
|
||||
this.line.geometry.dispose();
|
||||
this.line.material.dispose();
|
||||
this.cone.geometry.dispose();
|
||||
this.cone.material.dispose();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
export { ArrowHelper };
|
68
site/game/node_modules/three/src/helpers/AxesHelper.js
generated
vendored
Normal file
68
site/game/node_modules/three/src/helpers/AxesHelper.js
generated
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
import { LineSegments } from '../objects/LineSegments.js';
|
||||
import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
|
||||
import { Float32BufferAttribute } from '../core/BufferAttribute.js';
|
||||
import { BufferGeometry } from '../core/BufferGeometry.js';
|
||||
import { Color } from '../math/Color.js';
|
||||
|
||||
class AxesHelper extends LineSegments {
|
||||
|
||||
constructor( size = 1 ) {
|
||||
|
||||
const vertices = [
|
||||
0, 0, 0, size, 0, 0,
|
||||
0, 0, 0, 0, size, 0,
|
||||
0, 0, 0, 0, 0, size
|
||||
];
|
||||
|
||||
const colors = [
|
||||
1, 0, 0, 1, 0.6, 0,
|
||||
0, 1, 0, 0.6, 1, 0,
|
||||
0, 0, 1, 0, 0.6, 1
|
||||
];
|
||||
|
||||
const geometry = new BufferGeometry();
|
||||
geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
|
||||
geometry.setAttribute( 'color', new Float32BufferAttribute( colors, 3 ) );
|
||||
|
||||
const material = new LineBasicMaterial( { vertexColors: true, toneMapped: false } );
|
||||
|
||||
super( geometry, material );
|
||||
|
||||
this.type = 'AxesHelper';
|
||||
|
||||
}
|
||||
|
||||
setColors( xAxisColor, yAxisColor, zAxisColor ) {
|
||||
|
||||
const color = new Color();
|
||||
const array = this.geometry.attributes.color.array;
|
||||
|
||||
color.set( xAxisColor );
|
||||
color.toArray( array, 0 );
|
||||
color.toArray( array, 3 );
|
||||
|
||||
color.set( yAxisColor );
|
||||
color.toArray( array, 6 );
|
||||
color.toArray( array, 9 );
|
||||
|
||||
color.set( zAxisColor );
|
||||
color.toArray( array, 12 );
|
||||
color.toArray( array, 15 );
|
||||
|
||||
this.geometry.attributes.color.needsUpdate = true;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
dispose() {
|
||||
|
||||
this.geometry.dispose();
|
||||
this.material.dispose();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
export { AxesHelper };
|
55
site/game/node_modules/three/src/helpers/Box3Helper.js
generated
vendored
Normal file
55
site/game/node_modules/three/src/helpers/Box3Helper.js
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
import { LineSegments } from '../objects/LineSegments.js';
|
||||
import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
|
||||
import { BufferAttribute, Float32BufferAttribute } from '../core/BufferAttribute.js';
|
||||
import { BufferGeometry } from '../core/BufferGeometry.js';
|
||||
|
||||
class Box3Helper extends LineSegments {
|
||||
|
||||
constructor( box, color = 0xffff00 ) {
|
||||
|
||||
const indices = new Uint16Array( [ 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7 ] );
|
||||
|
||||
const positions = [ 1, 1, 1, - 1, 1, 1, - 1, - 1, 1, 1, - 1, 1, 1, 1, - 1, - 1, 1, - 1, - 1, - 1, - 1, 1, - 1, - 1 ];
|
||||
|
||||
const geometry = new BufferGeometry();
|
||||
|
||||
geometry.setIndex( new BufferAttribute( indices, 1 ) );
|
||||
|
||||
geometry.setAttribute( 'position', new Float32BufferAttribute( positions, 3 ) );
|
||||
|
||||
super( geometry, new LineBasicMaterial( { color: color, toneMapped: false } ) );
|
||||
|
||||
this.box = box;
|
||||
|
||||
this.type = 'Box3Helper';
|
||||
|
||||
this.geometry.computeBoundingSphere();
|
||||
|
||||
}
|
||||
|
||||
updateMatrixWorld( force ) {
|
||||
|
||||
const box = this.box;
|
||||
|
||||
if ( box.isEmpty() ) return;
|
||||
|
||||
box.getCenter( this.position );
|
||||
|
||||
box.getSize( this.scale );
|
||||
|
||||
this.scale.multiplyScalar( 0.5 );
|
||||
|
||||
super.updateMatrixWorld( force );
|
||||
|
||||
}
|
||||
|
||||
dispose() {
|
||||
|
||||
this.geometry.dispose();
|
||||
this.material.dispose();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { Box3Helper };
|
113
site/game/node_modules/three/src/helpers/BoxHelper.js
generated
vendored
Normal file
113
site/game/node_modules/three/src/helpers/BoxHelper.js
generated
vendored
Normal file
@ -0,0 +1,113 @@
|
||||
import { Box3 } from '../math/Box3.js';
|
||||
import { LineSegments } from '../objects/LineSegments.js';
|
||||
import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
|
||||
import { BufferAttribute } from '../core/BufferAttribute.js';
|
||||
import { BufferGeometry } from '../core/BufferGeometry.js';
|
||||
|
||||
const _box = /*@__PURE__*/ new Box3();
|
||||
|
||||
class BoxHelper extends LineSegments {
|
||||
|
||||
constructor( object, color = 0xffff00 ) {
|
||||
|
||||
const indices = new Uint16Array( [ 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7 ] );
|
||||
const positions = new Float32Array( 8 * 3 );
|
||||
|
||||
const geometry = new BufferGeometry();
|
||||
geometry.setIndex( new BufferAttribute( indices, 1 ) );
|
||||
geometry.setAttribute( 'position', new BufferAttribute( positions, 3 ) );
|
||||
|
||||
super( geometry, new LineBasicMaterial( { color: color, toneMapped: false } ) );
|
||||
|
||||
this.object = object;
|
||||
this.type = 'BoxHelper';
|
||||
|
||||
this.matrixAutoUpdate = false;
|
||||
|
||||
this.update();
|
||||
|
||||
}
|
||||
|
||||
update( object ) {
|
||||
|
||||
if ( object !== undefined ) {
|
||||
|
||||
console.warn( 'THREE.BoxHelper: .update() has no longer arguments.' );
|
||||
|
||||
}
|
||||
|
||||
if ( this.object !== undefined ) {
|
||||
|
||||
_box.setFromObject( this.object );
|
||||
|
||||
}
|
||||
|
||||
if ( _box.isEmpty() ) return;
|
||||
|
||||
const min = _box.min;
|
||||
const max = _box.max;
|
||||
|
||||
/*
|
||||
5____4
|
||||
1/___0/|
|
||||
| 6__|_7
|
||||
2/___3/
|
||||
|
||||
0: max.x, max.y, max.z
|
||||
1: min.x, max.y, max.z
|
||||
2: min.x, min.y, max.z
|
||||
3: max.x, min.y, max.z
|
||||
4: max.x, max.y, min.z
|
||||
5: min.x, max.y, min.z
|
||||
6: min.x, min.y, min.z
|
||||
7: max.x, min.y, min.z
|
||||
*/
|
||||
|
||||
const position = this.geometry.attributes.position;
|
||||
const array = position.array;
|
||||
|
||||
array[ 0 ] = max.x; array[ 1 ] = max.y; array[ 2 ] = max.z;
|
||||
array[ 3 ] = min.x; array[ 4 ] = max.y; array[ 5 ] = max.z;
|
||||
array[ 6 ] = min.x; array[ 7 ] = min.y; array[ 8 ] = max.z;
|
||||
array[ 9 ] = max.x; array[ 10 ] = min.y; array[ 11 ] = max.z;
|
||||
array[ 12 ] = max.x; array[ 13 ] = max.y; array[ 14 ] = min.z;
|
||||
array[ 15 ] = min.x; array[ 16 ] = max.y; array[ 17 ] = min.z;
|
||||
array[ 18 ] = min.x; array[ 19 ] = min.y; array[ 20 ] = min.z;
|
||||
array[ 21 ] = max.x; array[ 22 ] = min.y; array[ 23 ] = min.z;
|
||||
|
||||
position.needsUpdate = true;
|
||||
|
||||
this.geometry.computeBoundingSphere();
|
||||
|
||||
}
|
||||
|
||||
setFromObject( object ) {
|
||||
|
||||
this.object = object;
|
||||
this.update();
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
copy( source, recursive ) {
|
||||
|
||||
super.copy( source, recursive );
|
||||
|
||||
this.object = source.object;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
dispose() {
|
||||
|
||||
this.geometry.dispose();
|
||||
this.material.dispose();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
export { BoxHelper };
|
269
site/game/node_modules/three/src/helpers/CameraHelper.js
generated
vendored
Normal file
269
site/game/node_modules/three/src/helpers/CameraHelper.js
generated
vendored
Normal file
@ -0,0 +1,269 @@
|
||||
import { Camera } from '../cameras/Camera.js';
|
||||
import { Vector3 } from '../math/Vector3.js';
|
||||
import { LineSegments } from '../objects/LineSegments.js';
|
||||
import { Color } from '../math/Color.js';
|
||||
import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
|
||||
import { BufferGeometry } from '../core/BufferGeometry.js';
|
||||
import { Float32BufferAttribute } from '../core/BufferAttribute.js';
|
||||
|
||||
const _vector = /*@__PURE__*/ new Vector3();
|
||||
const _camera = /*@__PURE__*/ new Camera();
|
||||
|
||||
/**
|
||||
* - shows frustum, line of sight and up of the camera
|
||||
* - suitable for fast updates
|
||||
* - based on frustum visualization in lightgl.js shadowmap example
|
||||
* https://github.com/evanw/lightgl.js/blob/master/tests/shadowmap.html
|
||||
*/
|
||||
|
||||
class CameraHelper extends LineSegments {
|
||||
|
||||
constructor( camera ) {
|
||||
|
||||
const geometry = new BufferGeometry();
|
||||
const material = new LineBasicMaterial( { color: 0xffffff, vertexColors: true, toneMapped: false } );
|
||||
|
||||
const vertices = [];
|
||||
const colors = [];
|
||||
|
||||
const pointMap = {};
|
||||
|
||||
// near
|
||||
|
||||
addLine( 'n1', 'n2' );
|
||||
addLine( 'n2', 'n4' );
|
||||
addLine( 'n4', 'n3' );
|
||||
addLine( 'n3', 'n1' );
|
||||
|
||||
// far
|
||||
|
||||
addLine( 'f1', 'f2' );
|
||||
addLine( 'f2', 'f4' );
|
||||
addLine( 'f4', 'f3' );
|
||||
addLine( 'f3', 'f1' );
|
||||
|
||||
// sides
|
||||
|
||||
addLine( 'n1', 'f1' );
|
||||
addLine( 'n2', 'f2' );
|
||||
addLine( 'n3', 'f3' );
|
||||
addLine( 'n4', 'f4' );
|
||||
|
||||
// cone
|
||||
|
||||
addLine( 'p', 'n1' );
|
||||
addLine( 'p', 'n2' );
|
||||
addLine( 'p', 'n3' );
|
||||
addLine( 'p', 'n4' );
|
||||
|
||||
// up
|
||||
|
||||
addLine( 'u1', 'u2' );
|
||||
addLine( 'u2', 'u3' );
|
||||
addLine( 'u3', 'u1' );
|
||||
|
||||
// target
|
||||
|
||||
addLine( 'c', 't' );
|
||||
addLine( 'p', 'c' );
|
||||
|
||||
// cross
|
||||
|
||||
addLine( 'cn1', 'cn2' );
|
||||
addLine( 'cn3', 'cn4' );
|
||||
|
||||
addLine( 'cf1', 'cf2' );
|
||||
addLine( 'cf3', 'cf4' );
|
||||
|
||||
function addLine( a, b ) {
|
||||
|
||||
addPoint( a );
|
||||
addPoint( b );
|
||||
|
||||
}
|
||||
|
||||
function addPoint( id ) {
|
||||
|
||||
vertices.push( 0, 0, 0 );
|
||||
colors.push( 0, 0, 0 );
|
||||
|
||||
if ( pointMap[ id ] === undefined ) {
|
||||
|
||||
pointMap[ id ] = [];
|
||||
|
||||
}
|
||||
|
||||
pointMap[ id ].push( ( vertices.length / 3 ) - 1 );
|
||||
|
||||
}
|
||||
|
||||
geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
|
||||
geometry.setAttribute( 'color', new Float32BufferAttribute( colors, 3 ) );
|
||||
|
||||
super( geometry, material );
|
||||
|
||||
this.type = 'CameraHelper';
|
||||
|
||||
this.camera = camera;
|
||||
if ( this.camera.updateProjectionMatrix ) this.camera.updateProjectionMatrix();
|
||||
|
||||
this.matrix = camera.matrixWorld;
|
||||
this.matrixAutoUpdate = false;
|
||||
|
||||
this.pointMap = pointMap;
|
||||
|
||||
this.update();
|
||||
|
||||
// colors
|
||||
|
||||
const colorFrustum = new Color( 0xffaa00 );
|
||||
const colorCone = new Color( 0xff0000 );
|
||||
const colorUp = new Color( 0x00aaff );
|
||||
const colorTarget = new Color( 0xffffff );
|
||||
const colorCross = new Color( 0x333333 );
|
||||
|
||||
this.setColors( colorFrustum, colorCone, colorUp, colorTarget, colorCross );
|
||||
|
||||
}
|
||||
|
||||
setColors( frustum, cone, up, target, cross ) {
|
||||
|
||||
const geometry = this.geometry;
|
||||
|
||||
const colorAttribute = geometry.getAttribute( 'color' );
|
||||
|
||||
// near
|
||||
|
||||
colorAttribute.setXYZ( 0, frustum.r, frustum.g, frustum.b ); colorAttribute.setXYZ( 1, frustum.r, frustum.g, frustum.b ); // n1, n2
|
||||
colorAttribute.setXYZ( 2, frustum.r, frustum.g, frustum.b ); colorAttribute.setXYZ( 3, frustum.r, frustum.g, frustum.b ); // n2, n4
|
||||
colorAttribute.setXYZ( 4, frustum.r, frustum.g, frustum.b ); colorAttribute.setXYZ( 5, frustum.r, frustum.g, frustum.b ); // n4, n3
|
||||
colorAttribute.setXYZ( 6, frustum.r, frustum.g, frustum.b ); colorAttribute.setXYZ( 7, frustum.r, frustum.g, frustum.b ); // n3, n1
|
||||
|
||||
// far
|
||||
|
||||
colorAttribute.setXYZ( 8, frustum.r, frustum.g, frustum.b ); colorAttribute.setXYZ( 9, frustum.r, frustum.g, frustum.b ); // f1, f2
|
||||
colorAttribute.setXYZ( 10, frustum.r, frustum.g, frustum.b ); colorAttribute.setXYZ( 11, frustum.r, frustum.g, frustum.b ); // f2, f4
|
||||
colorAttribute.setXYZ( 12, frustum.r, frustum.g, frustum.b ); colorAttribute.setXYZ( 13, frustum.r, frustum.g, frustum.b ); // f4, f3
|
||||
colorAttribute.setXYZ( 14, frustum.r, frustum.g, frustum.b ); colorAttribute.setXYZ( 15, frustum.r, frustum.g, frustum.b ); // f3, f1
|
||||
|
||||
// sides
|
||||
|
||||
colorAttribute.setXYZ( 16, frustum.r, frustum.g, frustum.b ); colorAttribute.setXYZ( 17, frustum.r, frustum.g, frustum.b ); // n1, f1
|
||||
colorAttribute.setXYZ( 18, frustum.r, frustum.g, frustum.b ); colorAttribute.setXYZ( 19, frustum.r, frustum.g, frustum.b ); // n2, f2
|
||||
colorAttribute.setXYZ( 20, frustum.r, frustum.g, frustum.b ); colorAttribute.setXYZ( 21, frustum.r, frustum.g, frustum.b ); // n3, f3
|
||||
colorAttribute.setXYZ( 22, frustum.r, frustum.g, frustum.b ); colorAttribute.setXYZ( 23, frustum.r, frustum.g, frustum.b ); // n4, f4
|
||||
|
||||
// cone
|
||||
|
||||
colorAttribute.setXYZ( 24, cone.r, cone.g, cone.b ); colorAttribute.setXYZ( 25, cone.r, cone.g, cone.b ); // p, n1
|
||||
colorAttribute.setXYZ( 26, cone.r, cone.g, cone.b ); colorAttribute.setXYZ( 27, cone.r, cone.g, cone.b ); // p, n2
|
||||
colorAttribute.setXYZ( 28, cone.r, cone.g, cone.b ); colorAttribute.setXYZ( 29, cone.r, cone.g, cone.b ); // p, n3
|
||||
colorAttribute.setXYZ( 30, cone.r, cone.g, cone.b ); colorAttribute.setXYZ( 31, cone.r, cone.g, cone.b ); // p, n4
|
||||
|
||||
// up
|
||||
|
||||
colorAttribute.setXYZ( 32, up.r, up.g, up.b ); colorAttribute.setXYZ( 33, up.r, up.g, up.b ); // u1, u2
|
||||
colorAttribute.setXYZ( 34, up.r, up.g, up.b ); colorAttribute.setXYZ( 35, up.r, up.g, up.b ); // u2, u3
|
||||
colorAttribute.setXYZ( 36, up.r, up.g, up.b ); colorAttribute.setXYZ( 37, up.r, up.g, up.b ); // u3, u1
|
||||
|
||||
// target
|
||||
|
||||
colorAttribute.setXYZ( 38, target.r, target.g, target.b ); colorAttribute.setXYZ( 39, target.r, target.g, target.b ); // c, t
|
||||
colorAttribute.setXYZ( 40, cross.r, cross.g, cross.b ); colorAttribute.setXYZ( 41, cross.r, cross.g, cross.b ); // p, c
|
||||
|
||||
// cross
|
||||
|
||||
colorAttribute.setXYZ( 42, cross.r, cross.g, cross.b ); colorAttribute.setXYZ( 43, cross.r, cross.g, cross.b ); // cn1, cn2
|
||||
colorAttribute.setXYZ( 44, cross.r, cross.g, cross.b ); colorAttribute.setXYZ( 45, cross.r, cross.g, cross.b ); // cn3, cn4
|
||||
|
||||
colorAttribute.setXYZ( 46, cross.r, cross.g, cross.b ); colorAttribute.setXYZ( 47, cross.r, cross.g, cross.b ); // cf1, cf2
|
||||
colorAttribute.setXYZ( 48, cross.r, cross.g, cross.b ); colorAttribute.setXYZ( 49, cross.r, cross.g, cross.b ); // cf3, cf4
|
||||
|
||||
colorAttribute.needsUpdate = true;
|
||||
|
||||
}
|
||||
|
||||
update() {
|
||||
|
||||
const geometry = this.geometry;
|
||||
const pointMap = this.pointMap;
|
||||
|
||||
const w = 1, h = 1;
|
||||
|
||||
// we need just camera projection matrix inverse
|
||||
// world matrix must be identity
|
||||
|
||||
_camera.projectionMatrixInverse.copy( this.camera.projectionMatrixInverse );
|
||||
|
||||
// center / target
|
||||
|
||||
setPoint( 'c', pointMap, geometry, _camera, 0, 0, - 1 );
|
||||
setPoint( 't', pointMap, geometry, _camera, 0, 0, 1 );
|
||||
|
||||
// near
|
||||
|
||||
setPoint( 'n1', pointMap, geometry, _camera, - w, - h, - 1 );
|
||||
setPoint( 'n2', pointMap, geometry, _camera, w, - h, - 1 );
|
||||
setPoint( 'n3', pointMap, geometry, _camera, - w, h, - 1 );
|
||||
setPoint( 'n4', pointMap, geometry, _camera, w, h, - 1 );
|
||||
|
||||
// far
|
||||
|
||||
setPoint( 'f1', pointMap, geometry, _camera, - w, - h, 1 );
|
||||
setPoint( 'f2', pointMap, geometry, _camera, w, - h, 1 );
|
||||
setPoint( 'f3', pointMap, geometry, _camera, - w, h, 1 );
|
||||
setPoint( 'f4', pointMap, geometry, _camera, w, h, 1 );
|
||||
|
||||
// up
|
||||
|
||||
setPoint( 'u1', pointMap, geometry, _camera, w * 0.7, h * 1.1, - 1 );
|
||||
setPoint( 'u2', pointMap, geometry, _camera, - w * 0.7, h * 1.1, - 1 );
|
||||
setPoint( 'u3', pointMap, geometry, _camera, 0, h * 2, - 1 );
|
||||
|
||||
// cross
|
||||
|
||||
setPoint( 'cf1', pointMap, geometry, _camera, - w, 0, 1 );
|
||||
setPoint( 'cf2', pointMap, geometry, _camera, w, 0, 1 );
|
||||
setPoint( 'cf3', pointMap, geometry, _camera, 0, - h, 1 );
|
||||
setPoint( 'cf4', pointMap, geometry, _camera, 0, h, 1 );
|
||||
|
||||
setPoint( 'cn1', pointMap, geometry, _camera, - w, 0, - 1 );
|
||||
setPoint( 'cn2', pointMap, geometry, _camera, w, 0, - 1 );
|
||||
setPoint( 'cn3', pointMap, geometry, _camera, 0, - h, - 1 );
|
||||
setPoint( 'cn4', pointMap, geometry, _camera, 0, h, - 1 );
|
||||
|
||||
geometry.getAttribute( 'position' ).needsUpdate = true;
|
||||
|
||||
}
|
||||
|
||||
dispose() {
|
||||
|
||||
this.geometry.dispose();
|
||||
this.material.dispose();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function setPoint( point, pointMap, geometry, camera, x, y, z ) {
|
||||
|
||||
_vector.set( x, y, z ).unproject( camera );
|
||||
|
||||
const points = pointMap[ point ];
|
||||
|
||||
if ( points !== undefined ) {
|
||||
|
||||
const position = geometry.getAttribute( 'position' );
|
||||
|
||||
for ( let i = 0, l = points.length; i < l; i ++ ) {
|
||||
|
||||
position.setXYZ( points[ i ], _vector.x, _vector.y, _vector.z );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { CameraHelper };
|
93
site/game/node_modules/three/src/helpers/DirectionalLightHelper.js
generated
vendored
Normal file
93
site/game/node_modules/three/src/helpers/DirectionalLightHelper.js
generated
vendored
Normal file
@ -0,0 +1,93 @@
|
||||
import { Vector3 } from '../math/Vector3.js';
|
||||
import { Object3D } from '../core/Object3D.js';
|
||||
import { Line } from '../objects/Line.js';
|
||||
import { Float32BufferAttribute } from '../core/BufferAttribute.js';
|
||||
import { BufferGeometry } from '../core/BufferGeometry.js';
|
||||
import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
|
||||
|
||||
const _v1 = /*@__PURE__*/ new Vector3();
|
||||
const _v2 = /*@__PURE__*/ new Vector3();
|
||||
const _v3 = /*@__PURE__*/ new Vector3();
|
||||
|
||||
class DirectionalLightHelper extends Object3D {
|
||||
|
||||
constructor( light, size, color ) {
|
||||
|
||||
super();
|
||||
|
||||
this.light = light;
|
||||
|
||||
this.matrix = light.matrixWorld;
|
||||
this.matrixAutoUpdate = false;
|
||||
|
||||
this.color = color;
|
||||
|
||||
this.type = 'DirectionalLightHelper';
|
||||
|
||||
if ( size === undefined ) size = 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 ) );
|
||||
|
||||
const material = new LineBasicMaterial( { fog: false, toneMapped: false } );
|
||||
|
||||
this.lightPlane = new Line( geometry, material );
|
||||
this.add( this.lightPlane );
|
||||
|
||||
geometry = new BufferGeometry();
|
||||
geometry.setAttribute( 'position', new Float32BufferAttribute( [ 0, 0, 0, 0, 0, 1 ], 3 ) );
|
||||
|
||||
this.targetLine = new Line( geometry, material );
|
||||
this.add( this.targetLine );
|
||||
|
||||
this.update();
|
||||
|
||||
}
|
||||
|
||||
dispose() {
|
||||
|
||||
this.lightPlane.geometry.dispose();
|
||||
this.lightPlane.material.dispose();
|
||||
this.targetLine.geometry.dispose();
|
||||
this.targetLine.material.dispose();
|
||||
|
||||
}
|
||||
|
||||
update() {
|
||||
|
||||
this.light.updateWorldMatrix( true, false );
|
||||
this.light.target.updateWorldMatrix( true, false );
|
||||
|
||||
_v1.setFromMatrixPosition( this.light.matrixWorld );
|
||||
_v2.setFromMatrixPosition( this.light.target.matrixWorld );
|
||||
_v3.subVectors( _v2, _v1 );
|
||||
|
||||
this.lightPlane.lookAt( _v2 );
|
||||
|
||||
if ( this.color !== undefined ) {
|
||||
|
||||
this.lightPlane.material.color.set( this.color );
|
||||
this.targetLine.material.color.set( this.color );
|
||||
|
||||
} else {
|
||||
|
||||
this.lightPlane.material.color.copy( this.light.color );
|
||||
this.targetLine.material.color.copy( this.light.color );
|
||||
|
||||
}
|
||||
|
||||
this.targetLine.lookAt( _v2 );
|
||||
this.targetLine.scale.z = _v3.length();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
export { DirectionalLightHelper };
|
56
site/game/node_modules/three/src/helpers/GridHelper.js
generated
vendored
Normal file
56
site/game/node_modules/three/src/helpers/GridHelper.js
generated
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
import { LineSegments } from '../objects/LineSegments.js';
|
||||
import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
|
||||
import { Float32BufferAttribute } from '../core/BufferAttribute.js';
|
||||
import { BufferGeometry } from '../core/BufferGeometry.js';
|
||||
import { Color } from '../math/Color.js';
|
||||
|
||||
class GridHelper extends LineSegments {
|
||||
|
||||
constructor( size = 10, divisions = 10, color1 = 0x444444, color2 = 0x888888 ) {
|
||||
|
||||
color1 = new Color( color1 );
|
||||
color2 = new Color( color2 );
|
||||
|
||||
const center = divisions / 2;
|
||||
const step = size / divisions;
|
||||
const halfSize = size / 2;
|
||||
|
||||
const vertices = [], colors = [];
|
||||
|
||||
for ( let i = 0, j = 0, k = - halfSize; i <= divisions; i ++, k += step ) {
|
||||
|
||||
vertices.push( - halfSize, 0, k, halfSize, 0, k );
|
||||
vertices.push( k, 0, - halfSize, k, 0, halfSize );
|
||||
|
||||
const color = i === center ? color1 : color2;
|
||||
|
||||
color.toArray( colors, j ); j += 3;
|
||||
color.toArray( colors, j ); j += 3;
|
||||
color.toArray( colors, j ); j += 3;
|
||||
color.toArray( colors, j ); j += 3;
|
||||
|
||||
}
|
||||
|
||||
const geometry = new BufferGeometry();
|
||||
geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
|
||||
geometry.setAttribute( 'color', new Float32BufferAttribute( colors, 3 ) );
|
||||
|
||||
const material = new LineBasicMaterial( { vertexColors: true, toneMapped: false } );
|
||||
|
||||
super( geometry, material );
|
||||
|
||||
this.type = 'GridHelper';
|
||||
|
||||
}
|
||||
|
||||
dispose() {
|
||||
|
||||
this.geometry.dispose();
|
||||
this.material.dispose();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
export { GridHelper };
|
88
site/game/node_modules/three/src/helpers/HemisphereLightHelper.js
generated
vendored
Normal file
88
site/game/node_modules/three/src/helpers/HemisphereLightHelper.js
generated
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
import { Vector3 } from '../math/Vector3.js';
|
||||
import { Color } from '../math/Color.js';
|
||||
import { Object3D } from '../core/Object3D.js';
|
||||
import { Mesh } from '../objects/Mesh.js';
|
||||
import { MeshBasicMaterial } from '../materials/MeshBasicMaterial.js';
|
||||
import { OctahedronGeometry } from '../geometries/OctahedronGeometry.js';
|
||||
import { BufferAttribute } from '../core/BufferAttribute.js';
|
||||
|
||||
const _vector = /*@__PURE__*/ new Vector3();
|
||||
const _color1 = /*@__PURE__*/ new Color();
|
||||
const _color2 = /*@__PURE__*/ new Color();
|
||||
|
||||
class HemisphereLightHelper extends Object3D {
|
||||
|
||||
constructor( light, size, color ) {
|
||||
|
||||
super();
|
||||
|
||||
this.light = light;
|
||||
|
||||
this.matrix = light.matrixWorld;
|
||||
this.matrixAutoUpdate = false;
|
||||
|
||||
this.color = color;
|
||||
|
||||
this.type = 'HemisphereLightHelper';
|
||||
|
||||
const geometry = new OctahedronGeometry( size );
|
||||
geometry.rotateY( Math.PI * 0.5 );
|
||||
|
||||
this.material = new MeshBasicMaterial( { wireframe: true, fog: false, toneMapped: false } );
|
||||
if ( this.color === undefined ) this.material.vertexColors = true;
|
||||
|
||||
const position = geometry.getAttribute( 'position' );
|
||||
const colors = new Float32Array( position.count * 3 );
|
||||
|
||||
geometry.setAttribute( 'color', new BufferAttribute( colors, 3 ) );
|
||||
|
||||
this.add( new Mesh( geometry, this.material ) );
|
||||
|
||||
this.update();
|
||||
|
||||
}
|
||||
|
||||
dispose() {
|
||||
|
||||
this.children[ 0 ].geometry.dispose();
|
||||
this.children[ 0 ].material.dispose();
|
||||
|
||||
}
|
||||
|
||||
update() {
|
||||
|
||||
const mesh = this.children[ 0 ];
|
||||
|
||||
if ( this.color !== undefined ) {
|
||||
|
||||
this.material.color.set( this.color );
|
||||
|
||||
} else {
|
||||
|
||||
const colors = mesh.geometry.getAttribute( 'color' );
|
||||
|
||||
_color1.copy( this.light.color );
|
||||
_color2.copy( this.light.groundColor );
|
||||
|
||||
for ( let i = 0, l = colors.count; i < l; i ++ ) {
|
||||
|
||||
const color = ( i < ( l / 2 ) ) ? _color1 : _color2;
|
||||
|
||||
colors.setXYZ( i, color.r, color.g, color.b );
|
||||
|
||||
}
|
||||
|
||||
colors.needsUpdate = true;
|
||||
|
||||
}
|
||||
|
||||
this.light.updateWorldMatrix( true, false );
|
||||
|
||||
mesh.lookAt( _vector.setFromMatrixPosition( this.light.matrixWorld ).negate() );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
export { HemisphereLightHelper };
|
63
site/game/node_modules/three/src/helpers/PlaneHelper.js
generated
vendored
Normal file
63
site/game/node_modules/three/src/helpers/PlaneHelper.js
generated
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
import { Line } from '../objects/Line.js';
|
||||
import { Mesh } from '../objects/Mesh.js';
|
||||
import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
|
||||
import { MeshBasicMaterial } from '../materials/MeshBasicMaterial.js';
|
||||
import { Float32BufferAttribute } from '../core/BufferAttribute.js';
|
||||
import { BufferGeometry } from '../core/BufferGeometry.js';
|
||||
|
||||
class PlaneHelper extends Line {
|
||||
|
||||
constructor( plane, size = 1, hex = 0xffff00 ) {
|
||||
|
||||
const color = hex;
|
||||
|
||||
const positions = [ 1, - 1, 0, - 1, 1, 0, - 1, - 1, 0, 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();
|
||||
|
||||
super( geometry, new LineBasicMaterial( { color: color, toneMapped: false } ) );
|
||||
|
||||
this.type = 'PlaneHelper';
|
||||
|
||||
this.plane = plane;
|
||||
|
||||
this.size = size;
|
||||
|
||||
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( { color: color, opacity: 0.2, transparent: true, depthWrite: false, toneMapped: false } ) ) );
|
||||
|
||||
}
|
||||
|
||||
updateMatrixWorld( force ) {
|
||||
|
||||
this.position.set( 0, 0, 0 );
|
||||
|
||||
this.scale.set( 0.5 * this.size, 0.5 * this.size, 1 );
|
||||
|
||||
this.lookAt( this.plane.normal );
|
||||
|
||||
this.translateZ( - this.plane.constant );
|
||||
|
||||
super.updateMatrixWorld( force );
|
||||
|
||||
}
|
||||
|
||||
dispose() {
|
||||
|
||||
this.geometry.dispose();
|
||||
this.material.dispose();
|
||||
this.children[ 0 ].geometry.dispose();
|
||||
this.children[ 0 ].material.dispose();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { PlaneHelper };
|
92
site/game/node_modules/three/src/helpers/PointLightHelper.js
generated
vendored
Normal file
92
site/game/node_modules/three/src/helpers/PointLightHelper.js
generated
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
import { Mesh } from '../objects/Mesh.js';
|
||||
import { MeshBasicMaterial } from '../materials/MeshBasicMaterial.js';
|
||||
import { SphereGeometry } from '../geometries/SphereGeometry.js';
|
||||
|
||||
class PointLightHelper extends Mesh {
|
||||
|
||||
constructor( light, sphereSize, color ) {
|
||||
|
||||
const geometry = new SphereGeometry( sphereSize, 4, 2 );
|
||||
const material = new MeshBasicMaterial( { wireframe: true, fog: false, toneMapped: false } );
|
||||
|
||||
super( geometry, material );
|
||||
|
||||
this.light = light;
|
||||
|
||||
this.color = color;
|
||||
|
||||
this.type = 'PointLightHelper';
|
||||
|
||||
this.matrix = this.light.matrixWorld;
|
||||
this.matrixAutoUpdate = false;
|
||||
|
||||
this.update();
|
||||
|
||||
|
||||
/*
|
||||
// TODO: delete this comment?
|
||||
const distanceGeometry = new THREE.IcosahedronGeometry( 1, 2 );
|
||||
const distanceMaterial = new THREE.MeshBasicMaterial( { color: hexColor, fog: false, wireframe: true, opacity: 0.1, transparent: true } );
|
||||
|
||||
this.lightSphere = new THREE.Mesh( bulbGeometry, bulbMaterial );
|
||||
this.lightDistance = new THREE.Mesh( distanceGeometry, distanceMaterial );
|
||||
|
||||
const d = light.distance;
|
||||
|
||||
if ( d === 0.0 ) {
|
||||
|
||||
this.lightDistance.visible = false;
|
||||
|
||||
} else {
|
||||
|
||||
this.lightDistance.scale.set( d, d, d );
|
||||
|
||||
}
|
||||
|
||||
this.add( this.lightDistance );
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
dispose() {
|
||||
|
||||
this.geometry.dispose();
|
||||
this.material.dispose();
|
||||
|
||||
}
|
||||
|
||||
update() {
|
||||
|
||||
this.light.updateWorldMatrix( true, false );
|
||||
|
||||
if ( this.color !== undefined ) {
|
||||
|
||||
this.material.color.set( this.color );
|
||||
|
||||
} else {
|
||||
|
||||
this.material.color.copy( this.light.color );
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
const d = this.light.distance;
|
||||
|
||||
if ( d === 0.0 ) {
|
||||
|
||||
this.lightDistance.visible = false;
|
||||
|
||||
} else {
|
||||
|
||||
this.lightDistance.visible = true;
|
||||
this.lightDistance.scale.set( d, d, d );
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
export { PointLightHelper };
|
96
site/game/node_modules/three/src/helpers/PolarGridHelper.js
generated
vendored
Normal file
96
site/game/node_modules/three/src/helpers/PolarGridHelper.js
generated
vendored
Normal file
@ -0,0 +1,96 @@
|
||||
import { LineSegments } from '../objects/LineSegments.js';
|
||||
import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
|
||||
import { Float32BufferAttribute } from '../core/BufferAttribute.js';
|
||||
import { BufferGeometry } from '../core/BufferGeometry.js';
|
||||
import { Color } from '../math/Color.js';
|
||||
|
||||
class PolarGridHelper extends LineSegments {
|
||||
|
||||
constructor( radius = 10, sectors = 16, rings = 8, divisions = 64, color1 = 0x444444, color2 = 0x888888 ) {
|
||||
|
||||
color1 = new Color( color1 );
|
||||
color2 = new Color( color2 );
|
||||
|
||||
const vertices = [];
|
||||
const colors = [];
|
||||
|
||||
// create the sectors
|
||||
|
||||
if ( sectors > 1 ) {
|
||||
|
||||
for ( let i = 0; i < sectors; i ++ ) {
|
||||
|
||||
const v = ( i / sectors ) * ( Math.PI * 2 );
|
||||
|
||||
const x = Math.sin( v ) * radius;
|
||||
const z = Math.cos( v ) * radius;
|
||||
|
||||
vertices.push( 0, 0, 0 );
|
||||
vertices.push( x, 0, z );
|
||||
|
||||
const color = ( i & 1 ) ? color1 : color2;
|
||||
|
||||
colors.push( color.r, color.g, color.b );
|
||||
colors.push( color.r, color.g, color.b );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// create the rings
|
||||
|
||||
for ( let i = 0; i < rings; i ++ ) {
|
||||
|
||||
const color = ( i & 1 ) ? color1 : color2;
|
||||
|
||||
const r = radius - ( radius / rings * i );
|
||||
|
||||
for ( let j = 0; j < divisions; j ++ ) {
|
||||
|
||||
// first vertex
|
||||
|
||||
let v = ( j / divisions ) * ( Math.PI * 2 );
|
||||
|
||||
let x = Math.sin( v ) * r;
|
||||
let z = Math.cos( v ) * r;
|
||||
|
||||
vertices.push( x, 0, z );
|
||||
colors.push( color.r, color.g, color.b );
|
||||
|
||||
// second vertex
|
||||
|
||||
v = ( ( j + 1 ) / divisions ) * ( Math.PI * 2 );
|
||||
|
||||
x = Math.sin( v ) * r;
|
||||
z = Math.cos( v ) * r;
|
||||
|
||||
vertices.push( x, 0, z );
|
||||
colors.push( color.r, color.g, color.b );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const geometry = new BufferGeometry();
|
||||
geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
|
||||
geometry.setAttribute( 'color', new Float32BufferAttribute( colors, 3 ) );
|
||||
|
||||
const material = new LineBasicMaterial( { vertexColors: true, toneMapped: false } );
|
||||
|
||||
super( geometry, material );
|
||||
|
||||
this.type = 'PolarGridHelper';
|
||||
|
||||
}
|
||||
|
||||
dispose() {
|
||||
|
||||
this.geometry.dispose();
|
||||
this.material.dispose();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
export { PolarGridHelper };
|
128
site/game/node_modules/three/src/helpers/SkeletonHelper.js
generated
vendored
Normal file
128
site/game/node_modules/three/src/helpers/SkeletonHelper.js
generated
vendored
Normal file
@ -0,0 +1,128 @@
|
||||
import { LineSegments } from '../objects/LineSegments.js';
|
||||
import { Matrix4 } from '../math/Matrix4.js';
|
||||
import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
|
||||
import { Color } from '../math/Color.js';
|
||||
import { Vector3 } from '../math/Vector3.js';
|
||||
import { BufferGeometry } from '../core/BufferGeometry.js';
|
||||
import { Float32BufferAttribute } from '../core/BufferAttribute.js';
|
||||
|
||||
const _vector = /*@__PURE__*/ new Vector3();
|
||||
const _boneMatrix = /*@__PURE__*/ new Matrix4();
|
||||
const _matrixWorldInv = /*@__PURE__*/ new Matrix4();
|
||||
|
||||
|
||||
class SkeletonHelper extends LineSegments {
|
||||
|
||||
constructor( object ) {
|
||||
|
||||
const bones = getBoneList( object );
|
||||
|
||||
const geometry = new BufferGeometry();
|
||||
|
||||
const vertices = [];
|
||||
const colors = [];
|
||||
|
||||
const color1 = new Color( 0, 0, 1 );
|
||||
const color2 = new Color( 0, 1, 0 );
|
||||
|
||||
for ( let i = 0; i < bones.length; i ++ ) {
|
||||
|
||||
const bone = bones[ i ];
|
||||
|
||||
if ( bone.parent && bone.parent.isBone ) {
|
||||
|
||||
vertices.push( 0, 0, 0 );
|
||||
vertices.push( 0, 0, 0 );
|
||||
colors.push( color1.r, color1.g, color1.b );
|
||||
colors.push( color2.r, color2.g, color2.b );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
|
||||
geometry.setAttribute( 'color', new Float32BufferAttribute( colors, 3 ) );
|
||||
|
||||
const material = new LineBasicMaterial( { vertexColors: true, depthTest: false, depthWrite: false, toneMapped: false, transparent: true } );
|
||||
|
||||
super( geometry, material );
|
||||
|
||||
this.isSkeletonHelper = true;
|
||||
|
||||
this.type = 'SkeletonHelper';
|
||||
|
||||
this.root = object;
|
||||
this.bones = bones;
|
||||
|
||||
this.matrix = object.matrixWorld;
|
||||
this.matrixAutoUpdate = false;
|
||||
|
||||
}
|
||||
|
||||
updateMatrixWorld( force ) {
|
||||
|
||||
const bones = this.bones;
|
||||
|
||||
const geometry = this.geometry;
|
||||
const position = geometry.getAttribute( 'position' );
|
||||
|
||||
_matrixWorldInv.copy( this.root.matrixWorld ).invert();
|
||||
|
||||
for ( let i = 0, j = 0; i < bones.length; i ++ ) {
|
||||
|
||||
const bone = bones[ i ];
|
||||
|
||||
if ( bone.parent && bone.parent.isBone ) {
|
||||
|
||||
_boneMatrix.multiplyMatrices( _matrixWorldInv, bone.matrixWorld );
|
||||
_vector.setFromMatrixPosition( _boneMatrix );
|
||||
position.setXYZ( j, _vector.x, _vector.y, _vector.z );
|
||||
|
||||
_boneMatrix.multiplyMatrices( _matrixWorldInv, bone.parent.matrixWorld );
|
||||
_vector.setFromMatrixPosition( _boneMatrix );
|
||||
position.setXYZ( j + 1, _vector.x, _vector.y, _vector.z );
|
||||
|
||||
j += 2;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
geometry.getAttribute( 'position' ).needsUpdate = true;
|
||||
|
||||
super.updateMatrixWorld( force );
|
||||
|
||||
}
|
||||
|
||||
dispose() {
|
||||
|
||||
this.geometry.dispose();
|
||||
this.material.dispose();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function getBoneList( object ) {
|
||||
|
||||
const boneList = [];
|
||||
|
||||
if ( object.isBone === true ) {
|
||||
|
||||
boneList.push( object );
|
||||
|
||||
}
|
||||
|
||||
for ( let i = 0; i < object.children.length; i ++ ) {
|
||||
|
||||
boneList.push.apply( boneList, getBoneList( object.children[ i ] ) );
|
||||
|
||||
}
|
||||
|
||||
return boneList;
|
||||
|
||||
}
|
||||
|
||||
|
||||
export { SkeletonHelper };
|
111
site/game/node_modules/three/src/helpers/SpotLightHelper.js
generated
vendored
Normal file
111
site/game/node_modules/three/src/helpers/SpotLightHelper.js
generated
vendored
Normal file
@ -0,0 +1,111 @@
|
||||
import { Vector3 } from '../math/Vector3.js';
|
||||
import { Object3D } from '../core/Object3D.js';
|
||||
import { LineSegments } from '../objects/LineSegments.js';
|
||||
import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
|
||||
import { Float32BufferAttribute } from '../core/BufferAttribute.js';
|
||||
import { BufferGeometry } from '../core/BufferGeometry.js';
|
||||
|
||||
const _vector = /*@__PURE__*/ new Vector3();
|
||||
|
||||
class SpotLightHelper extends Object3D {
|
||||
|
||||
constructor( light, color ) {
|
||||
|
||||
super();
|
||||
|
||||
this.light = light;
|
||||
|
||||
this.matrixAutoUpdate = false;
|
||||
|
||||
this.color = color;
|
||||
|
||||
this.type = 'SpotLightHelper';
|
||||
|
||||
const geometry = new BufferGeometry();
|
||||
|
||||
const positions = [
|
||||
0, 0, 0, 0, 0, 1,
|
||||
0, 0, 0, 1, 0, 1,
|
||||
0, 0, 0, - 1, 0, 1,
|
||||
0, 0, 0, 0, 1, 1,
|
||||
0, 0, 0, 0, - 1, 1
|
||||
];
|
||||
|
||||
for ( let i = 0, j = 1, l = 32; i < l; i ++, j ++ ) {
|
||||
|
||||
const p1 = ( i / l ) * Math.PI * 2;
|
||||
const p2 = ( j / l ) * Math.PI * 2;
|
||||
|
||||
positions.push(
|
||||
Math.cos( p1 ), Math.sin( p1 ), 1,
|
||||
Math.cos( p2 ), Math.sin( p2 ), 1
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
geometry.setAttribute( 'position', new Float32BufferAttribute( positions, 3 ) );
|
||||
|
||||
const material = new LineBasicMaterial( { fog: false, toneMapped: false } );
|
||||
|
||||
this.cone = new LineSegments( geometry, material );
|
||||
this.add( this.cone );
|
||||
|
||||
this.update();
|
||||
|
||||
}
|
||||
|
||||
dispose() {
|
||||
|
||||
this.cone.geometry.dispose();
|
||||
this.cone.material.dispose();
|
||||
|
||||
}
|
||||
|
||||
update() {
|
||||
|
||||
this.light.updateWorldMatrix( true, false );
|
||||
this.light.target.updateWorldMatrix( true, false );
|
||||
|
||||
// update the local matrix based on the parent and light target transforms
|
||||
if ( this.parent ) {
|
||||
|
||||
this.parent.updateWorldMatrix( true );
|
||||
|
||||
this.matrix
|
||||
.copy( this.parent.matrixWorld )
|
||||
.invert()
|
||||
.multiply( this.light.matrixWorld );
|
||||
|
||||
} else {
|
||||
|
||||
this.matrix.copy( this.light.matrixWorld );
|
||||
|
||||
}
|
||||
|
||||
this.matrixWorld.copy( this.light.matrixWorld );
|
||||
|
||||
const coneLength = this.light.distance ? this.light.distance : 1000;
|
||||
const coneWidth = coneLength * Math.tan( this.light.angle );
|
||||
|
||||
this.cone.scale.set( coneWidth, coneWidth, coneLength );
|
||||
|
||||
_vector.setFromMatrixPosition( this.light.target.matrixWorld );
|
||||
|
||||
this.cone.lookAt( _vector );
|
||||
|
||||
if ( this.color !== undefined ) {
|
||||
|
||||
this.cone.material.color.set( this.color );
|
||||
|
||||
} else {
|
||||
|
||||
this.cone.material.color.copy( this.light.color );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
export { SpotLightHelper };
|
Reference in New Issue
Block a user