Skip to content

Instantly share code, notes, and snippets.

View flushpot1125's full-sized avatar

Limes2018 flushpot1125

View GitHub Profile
var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 5, -10), scene);
// This targets the camera to scene origin
//camera.setTarget(BABYLON.Vector3.Zero());
// This attaches the camera to the canvas
camera.attachControl(canvas, true);
//Box on Babylon.js
var box = BABYLON.MeshBuilder.CreateBox("box", {height:1, width:1, depth:1});
//explosion.ts
export function _generateSmoke( generatePos:Vector3):void{
// Start the particle system
let particleSystem:ParticleSystem;
let scene : SceneManager;
//以降処理が続く
}
export function _explode(impactPos : Vector3):void{
//move.ts
import Test from "./test";
private _test:Test;
public onStart(): void {
console.log(this._test._testNumber);
this._test.showLog();
}
//
ballInstance.actionManager = new ActionManager(this._scene);
ballInstance.actionManager.registerAction(
new ExecuteCodeAction(
{
trigger: ActionManager.OnIntersectionEnterTrigger,
parameter: this._largeRock,
},
() => {
_generateSmoke(ballInstance.position);
_explode(this._largeRock.position);
private _impluseShot():void{
const ballInstance = this._ball.createInstance("ballInstance");
ballInstance.position.copyFrom(this._ball.getAbsolutePosition());
ballInstance.scaling = new Vector3(10,10,10);
ballInstance.isVisible=false;//非表示になる
//・・・
private _swordSlashAnimNoExeFlag : boolean;
public onUpdate(): void {
if(this._swordSlashAnimNoExeFlag == false){//剣を振るアニメーションが発動されていたらif文を通過する
if(this._animSwordAndShieldSlash.animatables[0].animationStarted == true){//アニメーションが実行されていないと、animationStartedが存在しないと表示され処理が止まる
if (this._animSwordAndShieldSlash.animatables[0].masterFrame < 0.8 && this._animSwordAndShieldSlash.animatables[0].masterFrame > 0.7){
this._impluseShot();//衝撃波を発生させる関数
this._swordSlashAnimFlag = true;//もう一度呼ばれないようにtrueに変更
}
}
//Referred from https://playground.babylonjs.com/#0YT4XN#5
var pointLight = new BABYLON.PointLight("light1", new BABYLON.Vector3(0, 0, 0), scene);
pointLight.intensity = 2;
pointLight.diffuse = new BABYLON.Color3(0.59, 0.48, 0.33)
pointLight.parent = sphere
@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);
var glowLayer = new BABYLON.GlowLayer ("glow",scene);
glowLayer.customEmissiveColorSelector = function(mesh, subMesh, material, result) {
if (mesh.name === "shockWave") {
result.set(1, 0.63, 0.3, 1);// orange glow layer
} else {
result.set(0, 0, 0, 0);//no glow layer
}
}