Dart DocumentationthreeSprite

Sprite class

class Sprite extends Object3D {
 Color color;
 Texture map;

 int blending;
 int blendSrc;

 int blendDst;
 int blendEquation;

 bool useScreenCoordinates;
 bool mergeWith3D;
 bool affectedByDistance;
 bool scaleByViewport;

 Vector2 alignment;

 Vector3 rotation3d;

 num opacity;

 Vector2 uvOffset, uvScale;

 Sprite({  num hexColor: 0xffffff,
           this.map,
           this.blending: NormalBlending,
           this.blendSrc: SrcAlphaFactor,
           this.blendDst: OneMinusSrcAlphaFactor,
           this.blendEquation: AddEquation,

           this.useScreenCoordinates: true,

           bool mergeWith3D: null,
           bool affectedByDistance: null,
           bool scaleByViewport: null,

           Vector2 alignment: null})

           : color = new Color(hexColor),
             uvOffset = new Vector2.zero(),
             uvScale = new Vector2(1.0, 1.0),
             opacity = 1,
             super() {

   if (map == null) map = new Texture();
   if (mergeWith3D == null)  this.mergeWith3D = !useScreenCoordinates;
   if (affectedByDistance == null)  this.affectedByDistance = !useScreenCoordinates;
   if (scaleByViewport == null)  this.scaleByViewport = !affectedByDistance;

   if (alignment == null) this.alignment = SpriteAlignment.center;

   rotation3d = rotation;
 }
}

Extends

Object3D > Sprite

Constructors

new Sprite({num hexColor: 0xffffff, Texture map, int blending: NormalBlending, int blendSrc: SrcAlphaFactor, int blendDst: OneMinusSrcAlphaFactor, int blendEquation: AddEquation, bool useScreenCoordinates: true, bool mergeWith3D: null, bool affectedByDistance: null, bool scaleByViewport: null, Vector2 alignment: null}) #

Creates a new Object instance.

Object instances have no meaningful state, and are only useful through their identity. An Object instance is equal to itself only.

docs inherited from Object
Sprite({  num hexColor: 0xffffff,
         this.map,
         this.blending: NormalBlending,
         this.blendSrc: SrcAlphaFactor,
         this.blendDst: OneMinusSrcAlphaFactor,
         this.blendEquation: AddEquation,

         this.useScreenCoordinates: true,

         bool mergeWith3D: null,
         bool affectedByDistance: null,
         bool scaleByViewport: null,

         Vector2 alignment: null})

         : color = new Color(hexColor),
           uvOffset = new Vector2.zero(),
           uvScale = new Vector2(1.0, 1.0),
           opacity = 1,
           super() {

 if (map == null) map = new Texture();
 if (mergeWith3D == null)  this.mergeWith3D = !useScreenCoordinates;
 if (affectedByDistance == null)  this.affectedByDistance = !useScreenCoordinates;
 if (scaleByViewport == null)  this.scaleByViewport = !affectedByDistance;

 if (alignment == null) this.alignment = SpriteAlignment.center;

 rotation3d = rotation;
}

Properties

bool affectedByDistance #

bool affectedByDistance

Vector2 alignment #

Vector2 alignment

int blendDst #

int blendDst

int blendEquation #

int blendEquation

int blending #

int blending

int blendSrc #

int blendSrc

num boundRadius #

inherited from Object3D
num boundRadius

num boundRadiusScale #

inherited from Object3D
num boundRadius, boundRadiusScale

bool castShadow #

inherited from Object3D
bool visible = false, castShadow = false

List children #

inherited from Object3D
List children

Color color #

Color color

var customDepthMaterial #

inherited from Object3D
var customDepthMaterial

bool doubleSided #

inherited from Object3D
bool _dynamic, doubleSided

String eulerOrder #

inherited from Object3D
String eulerOrder

bool flipSided #

inherited from Object3D
bool _dynamic, doubleSided, flipSided

bool frustumCulled #

inherited from Object3D
bool visible = false, castShadow = false, receiveShadow = false, frustumCulled = false

int id #

inherited from Object3D
int id

bool isDynamic #

inherited from Object3D
bool get isDynamic => _dynamic;
set isDynamic(bool flag) => _dynamic = flag;

Texture map #

Texture map

Matrix4 matrix #

inherited from Object3D
Matrix4 matrix

bool matrixAutoUpdate #

inherited from Object3D
bool matrixAutoUpdate = false

Matrix4 matrixRotationWorld #

inherited from Object3D
Matrix4 matrix, matrixWorld, matrixRotationWorld

Matrix4 matrixWorld #

inherited from Object3D
Matrix4 matrix, matrixWorld

bool matrixWorldNeedsUpdate #

inherited from Object3D
bool matrixAutoUpdate = false, matrixWorldNeedsUpdate = false

bool mergeWith3D #

bool mergeWith3D

String name #

inherited from Object3D
String name

num opacity #

num opacity

Object3D parent #

inherited from Object3D
Object3D parent

Vector3 position #

inherited from Object3D
Vector3 up, position

Map properties #

inherited from Object3D
Map properties

var quaternion #

inherited from Object3D
var quaternion

bool receiveShadow #

inherited from Object3D
bool visible = false, castShadow = false, receiveShadow = false

int renderDepth #

inherited from Object3D
int renderDepth

Vector3 rotation #

inherited from Object3D
Vector3 up, position, rotation

Vector3 rotation3d #

Vector3 rotation3d

bool rotationAutoUpdate #

inherited from Object3D
bool _dynamic, doubleSided, flipSided, rotationAutoUpdate

Vector3 scale #

inherited from Object3D
Vector3 up, position, rotation, scale

bool scaleByViewport #

bool scaleByViewport

Vector3 up #

inherited from Object3D
Vector3 up

bool useQuaternion #

inherited from Object3D
bool useQuaternion

bool useScreenCoordinates #

bool useScreenCoordinates

Vector2 uvOffset #

Vector2 uvOffset

Vector2 uvScale #

Vector2 uvOffset, uvScale

bool visible #

inherited from Object3D
bool visible = false

Operators

dynamic operator [](String key) #

inherited from Object3D
operator [] (String key) => _data[key];

dynamic operator []=(String key, value) #

inherited from Object3D
operator []= (String key, value) => _data[key] = value;

Methods

void add(Object3D object) #

inherited from Object3D
void add( Object3D object ) {
 if ( object == this ) {
   print( 'THREE.Object3D.add: An object can\'t be added as a child of itself.' );
   return;
 }


 if ( object.parent != null ) {
   object.parent.remove( object );
 }

 object.parent = this;
 children.add( object );

 // add to scene
 Object3D scene = this;

 while ( scene.parent != null ) {
   scene = scene.parent;
 }

 if ( scene is Scene ) {
   scene.addObject( object );
 }

}

void applyMatrix(Matrix4 matrix) #

inherited from Object3D
void applyMatrix ( Matrix4 matrix ) {
 this.matrix = matrix * this.matrix;

 this.scale = getScaleFromMatrix( this.matrix );

 Matrix4 mat = extractRotation(new Matrix4.identity(), this.matrix );
 this.rotation = calcEulerFromRotationMatrix( mat, this.eulerOrder );

 this.position = this.matrix.getTranslation();
}

dynamic clone() #

inherited from Object3D
clone() {

 // TODO

}

Object3D getChildByName(String name, bool doRecurse) #

inherited from Object3D
Object3D getChildByName( String name, bool doRecurse ) {
 int c;
 int cl = children.length;
 Object3D child, recurseResult;

 children.forEach((child){

   if ( child.name == name ) {
     return child;
   }

   if ( doRecurse ) {
     recurseResult = child.getChildByName( name, doRecurse );

     if ( recurseResult != null ) {
       return recurseResult;
     }
   }
 });

 return null;
}

dynamic localToWorld(Vector3 vector) #

inherited from Object3D
localToWorld(Vector3 vector) => vector.applyProjection(matrixWorld);

void lookAt(Vector3 vector) #

inherited from Object3D
void lookAt( Vector3 vector ) {
 // TODO: Add hierarchy support.

 makeLookAt( matrix, vector, position, up );

 if ( rotationAutoUpdate ) {
   if(useQuaternion)
     quaternion.setFromRotationMatrix(matrix);
   else
     rotation = calcEulerFromRotationMatrix( matrix, eulerOrder );
 }
}

void remove(Object3D object) #

inherited from Object3D
void remove( Object3D object ) {

 int index = children.indexOf( object );

 if ( index != - 1 ){

   object.parent = null;
   children.removeAt(index);

   // remove from scene
   Object3D scene = this;

   while ( scene.parent != null ) {
     scene = scene.parent;
   }

   if (scene is Scene ) {
     scene.removeObject( object );
   }
 }
}

void translate(num distance, Vector3 axis) #

inherited from Object3D
void translate( num distance, Vector3 axis ) {
 matrix.rotate3( axis );
 axis.normalize();
 position.add( axis.scale( distance ) );
}

void translateX(num distance) #

inherited from Object3D
void translateX( num distance ) => translate( distance, _vector.setValues( 1.0, 0.0, 0.0 ) );

void translateY(num distance) #

inherited from Object3D
void translateY( num distance ) => translate( distance, _vector.setValues( 0.0, 1.0, 0.0 ) );

void translateZ(num distance) #

inherited from Object3D
void translateZ( num distance ) => translate( distance, _vector.setValues( 0.0, 0.0, 1.0 ) );

void updateMatrix() #

inherited from Object3D
void updateMatrix() {

 if ( useQuaternion ) {
   setRotationFromQuaternion( matrix, quaternion );
 } else {
   setRotationFromEuler( matrix, rotation, eulerOrder );
 }

 matrix.setTranslation( position );

 if ( scale.x != 1.0 || scale.y != 1.0 || scale.z != 1.0 ) {
   matrix.scale( scale );
   boundRadiusScale = Math.max( scale.x, Math.max( scale.y, scale.z ) );
 }

 matrixWorldNeedsUpdate = true;
}

void updateMatrixWorld({bool force: false}) #

inherited from Object3D
void updateMatrixWorld( {bool force: false} ) {

if (matrixAutoUpdate) updateMatrix();

 // update matrixWorld
 if ( matrixWorldNeedsUpdate || force ) {
   if ( parent != null ) {
     matrixWorld = parent.matrixWorld * matrix;
   } else {
     matrixWorld = matrix.clone();
   }

   matrixWorldNeedsUpdate = false;

   force = true;
 }

 // update children
 children.forEach((c) => c.updateMatrixWorld( force: force ) );

}

dynamic worldToLocal(Vector3 vector) #

inherited from Object3D
worldToLocal(Vector3 vector) {
 Matrix4 m = this.matrixWorld.clone();
 m.invert();
 m.transform3( vector );
}