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
@onKeyboardEvent([75], KeyboardEventTypes.KEYUP)//K | |
private _impluseShot():void{ | |
// Create a new ball instance | |
const ballInstance = this._ball.createInstance("ballInstance"); | |
ballInstance.position.copyFrom(this._ball.getAbsolutePosition()); | |
ballInstance.scaling = new Vector3(10,10,10); | |
ballInstance.isVisible=false;//ballを見えなくして光だけにする | |
this._trailMeshBall = new TrailMesh("shockWave",ballInstance,this._scene,.1,30,true); | |
this._trailMaterialSource = new StandardMaterial('sourceMat', this._scene); | |
this._trailMaterialSource.emissiveColor = new Color3(1,0.63,1); | |
this._trailMaterialSource.diffuseColor = new Color3(1,1,1); | |
this._trailMaterialSource.specularColor = new Color3(1,0,1); | |
this._trailMaterialSource.ambientColor = new Color3(0,0,0); | |
this._trailMeshBall.material = this._trailMaterialSource; | |
this._glowLayer = new GlowLayer ("glow",this._scene); | |
this._glowLayer.customEmissiveColorSelector = function(mesh, subMesh, material, result) { | |
if (mesh.name === "shockWave") { | |
result.set(1, 0.63, 0, 1); | |
} else { | |
result.set(0, 0, 0, 0); | |
} | |
} | |
ballInstance.physicsImpostor = new PhysicsImpostor(ballInstance, PhysicsImpostor.SphereImpostor, { mass: 1000, friction: 0.2, restitution: 0.2 }); | |
var impulseMagnitude = 500000;//この値が大きいほど早く移動する | |
var contactLocalRefPoint = ballInstance.position; | |
var impulseDirection1 = new Vector3(0, 0, 1); | |
ballInstance.applyImpulse(impulseDirection1.scale(impulseMagnitude), ballInstance.getAbsolutePosition().add(contactLocalRefPoint)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment