-
-
Save cj/8b41f342d44cdae0d720e8ab5077af71 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* jshint esversion: 6 */ | |
var Test = pc.createScript('test'); | |
var Text = 90782882; | |
var Letter; | |
var START_POSITION = new pc.Vec3(0, 5, 0); | |
// initialize code called once per entity | |
Test.prototype.initialize = function () { | |
this._createLetter(); | |
}; | |
// update code called every frame | |
Test.prototype.update = function (dt) { | |
}; | |
// swap method called for script hot-reloading | |
// inherit your script state here | |
Test.prototype.swap = function (old) { | |
Letter.destroy(); | |
this._createLetter(); | |
}; | |
// to learn more about script anatomy, please read: | |
// https://developer.playcanvas.com/en/user-manual/scripting/ | |
// PRIVATE FUNCTIONS | |
Test.prototype._createLetter = function () { | |
const templateAsset = this.app.assets.get(Text); | |
Letter = templateAsset.resource.instantiate(); | |
// this.app.root.addChild(instance); | |
// const templates = this.app.root.findByName('Templates'); | |
// const Text = templates.findByName('Text'); | |
// const Letter = Text.clone(); | |
Letter.setPosition(START_POSITION); | |
Letter.script.textMesh.text = 'Hello World!'; | |
// Letter.name = "Hello World"; | |
Letter.addComponent("collision", { | |
type: 'mesh', | |
asset: Letter, | |
// halfExtends: new pc.Vec3(1, 1, 1) | |
}); | |
Letter.addComponent("rigidbody", { | |
type: pc.BODYTYPE_DYNAMIC, | |
}); | |
console.log(Letter); | |
this.app.root.addChild(Letter); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment