|
@@ -1,3 +1,8 @@
|
|
|
|
+/**
|
|
|
|
+ * @author mikael emtinger / http://gomo.se/
|
|
|
|
+ * @author alteredq / http://alteredqualia.com/
|
|
|
|
+ */
|
|
|
|
+
|
|
import { Vector2 } from '../math/Vector2.js';
|
|
import { Vector2 } from '../math/Vector2.js';
|
|
import { Vector3 } from '../math/Vector3.js';
|
|
import { Vector3 } from '../math/Vector3.js';
|
|
import { Matrix4 } from '../math/Matrix4.js';
|
|
import { Matrix4 } from '../math/Matrix4.js';
|
|
@@ -7,10 +12,7 @@ import { InterleavedBuffer } from '../core/InterleavedBuffer.js';
|
|
import { InterleavedBufferAttribute } from '../core/InterleavedBufferAttribute.js';
|
|
import { InterleavedBufferAttribute } from '../core/InterleavedBufferAttribute.js';
|
|
import { SpriteMaterial } from '../materials/SpriteMaterial.js';
|
|
import { SpriteMaterial } from '../materials/SpriteMaterial.js';
|
|
|
|
|
|
-/**
|
|
|
|
- * @author mikael emtinger / http://gomo.se/
|
|
|
|
- * @author alteredq / http://alteredqualia.com/
|
|
|
|
- */
|
|
|
|
|
|
+var geometry;
|
|
|
|
|
|
function Sprite( material ) {
|
|
function Sprite( material ) {
|
|
|
|
|
|
@@ -18,8 +20,27 @@ function Sprite( material ) {
|
|
|
|
|
|
this.type = 'Sprite';
|
|
this.type = 'Sprite';
|
|
|
|
|
|
|
|
+ if ( geometry === undefined ) {
|
|
|
|
+
|
|
|
|
+ geometry = new BufferGeometry();
|
|
|
|
+
|
|
|
|
+ var 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
|
|
|
|
+ ] );
|
|
|
|
+
|
|
|
|
+ var interleavedBuffer = new InterleavedBuffer( float32Array, 5 );
|
|
|
|
+
|
|
|
|
+ geometry.setIndex( [ 0, 1, 2, 0, 2, 3 ] );
|
|
|
|
+ geometry.addAttribute( 'position', new InterleavedBufferAttribute( interleavedBuffer, 3, 0, false ) );
|
|
|
|
+ geometry.addAttribute( 'uv', new InterleavedBufferAttribute( interleavedBuffer, 2, 3, false ) );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.geometry = geometry;
|
|
this.material = ( material !== undefined ) ? material : new SpriteMaterial();
|
|
this.material = ( material !== undefined ) ? material : new SpriteMaterial();
|
|
- this.geometry = SpriteGeometry;
|
|
|
|
|
|
|
|
this.center = new Vector2( 0.5, 0.5 );
|
|
this.center = new Vector2( 0.5, 0.5 );
|
|
|
|
|
|
@@ -145,27 +166,4 @@ Sprite.prototype = Object.assign( Object.create( Object3D.prototype ), {
|
|
|
|
|
|
} );
|
|
} );
|
|
|
|
|
|
-//
|
|
|
|
-
|
|
|
|
-var SpriteGeometry = ( function () {
|
|
|
|
-
|
|
|
|
- var geometry = new BufferGeometry();
|
|
|
|
-
|
|
|
|
- var 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
|
|
|
|
- ] );
|
|
|
|
-
|
|
|
|
- var interleavedBuffer = new InterleavedBuffer( float32Array, 5 );
|
|
|
|
-
|
|
|
|
- geometry.setIndex( [ 0, 1, 2, 0, 2, 3 ] );
|
|
|
|
- geometry.addAttribute( 'position', new InterleavedBufferAttribute( interleavedBuffer, 3, 0, false ) );
|
|
|
|
- geometry.addAttribute( 'uv', new InterleavedBufferAttribute( interleavedBuffer, 2, 3, false ) );
|
|
|
|
-
|
|
|
|
- return geometry;
|
|
|
|
-
|
|
|
|
-} )();
|
|
|
|
-
|
|
|
|
export { Sprite };
|
|
export { Sprite };
|