Greetings fellow users of stack overflow!
I've recently been experimenting with the world editor known as verold, based on three.js. The features it offers are quite impressive, but I've encountered an issue with the scripting aspect.
My current goal is to incorporate a THREE.Sprite() and attach it as a component of an object.
Below is my attempted code:
Component.prototype.objectCreated = function() {
// this.getThreeData() is available
this.spriteimage.load({
load:_.bind(function() {
this.createImageSprite();
}, this)
});
};
Component.prototype.createImageSprite = function(){
//Load the spriteimage
var map = this.spriteimage.threeData;
var spriteMaterial = new THREE.SpriteMaterial( { map: map, color: "rgb(255,0,0)", fog: true, useScreenCoordinates: false} );
var mySprite = new THREE.Sprite( spriteMaterial );
mySprite.scale.set(1,1,1);
mySprite.location.x = 0.5;
mySprite.location.y = 0.5;
mySprite.location.y = 0.5;
scene.add(mySprite);
};
The script features an attribute named spriteimage, which represents a verold asset - a 2D texture.
Although the project runs smoothly when this script is included as a scene component, the sprite remains invisible.
I've successfully replicated this code in a standard three.js project.
Any help or solutions you can provide would be greatly appreciated!
Thank you in advance.