Skip to content

Instantly share code, notes, and snippets.

Avatar

Limes2018 flushpot1125

View GitHub Profile
View gist:a2558229296f52a1c3664cf3775bc20b
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;//非表示になる
//・・・
View GenerateImpluseShot.ts
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に変更
}
}
View pointlight_child_object.js
//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
View bjs_editor_glowlayer_trailmesh.ts
@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);
View selected_mesh_with glow_layer.js
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
}
}
View trailmesh_example.js
var trailMeshSphere = new BABYLON.TrailMesh("shockWave",sphere,scene,1,100,true);
var trailMeshMaterial = new BABYLON.StandardMaterial('sourceMat', scene);
trailMeshMaterial.emmisiveColor =new BABYLON.Color3(1,0.63,1);
trailMeshMaterial.diffuseColor = new BABYLON.Color3(1,0.63,0.3);
trailMeshMaterial.specularColor = new BABYLON.Color3(0.5,0,1);
trailMeshMaterial.ambientColor = new BABYLON.Color3(1,1,1);
trailMeshSphere.material = trailMeshMaterial;
View attachToBone_BJS.ts
public onStart(): void {
this._leftArmBone = this._scene.getBoneByName("RightHandThumb1");
this._leftArmBone.position = new Vector3(0,0,0);
this._sword.position = new Vector3(0,0,0);
}
public onUpdate(): void {
this._sword.attachToBone(this._leftArmBone,this);
}
View Babylonjs-postprocess-example.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Babylon.js sample code</title>
<!-- Babylon.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.6.2/dat.gui.min.js"></script>
<script src="https://assets.babylonjs.com/generated/Assets.js"></script>
View flame.ts
import {
Mesh, ParticleSystem,AbstractMesh,TransformNode,KeyboardEventTypes
} from "@babylonjs/core";
import { visibleInInspector, onKeyboardEvent, fromScene, fromChildren } from "../tools";
import SceneManager from "./SceneManager";
export default class MyScript extends Mesh {
View flameParticle.json
{"name":"CPU particle system","id":"default system","capacity":1000,"disposeOnStop":false,"manualEmitCount":-1,"emitter":[0,0,0],"particleEmitterType":{"type":"SphereParticleEmitter","radius":1,"radiusRange":0.5,"directionRandomizer":0},"texture":{"tags":null,"url":"https://assets.babylonjs.com/textures/flare.png","uOffset":0,"vOffset":0,"uScale":1,"vScale":1,"uAng":0,"vAng":0,"wAng":0,"uRotationCenter":0.5,"vRotationCenter":0.5,"wRotationCenter":0.5,"homogeneousRotationInUVTransform":false,"isBlocking":true,"name":"https://assets.babylonjs.com/textures/flare.png","hasAlpha":false,"getAlphaFromRGB":false,"level":1,"coordinatesIndex":0,"coordinatesMode":0,"wrapU":1,"wrapV":1,"wrapR":1,"anisotropicFilteringLevel":4,"isCube":false,"is3D":false,"is2DArray":false,"gammaSpace":true,"invertZ":false,"lodLevelInAlpha":false,"lodGenerationOffset":0,"lodGenerationScale":0,"linearSpecularLOD":false,"isRenderTarget":false,"animations":[],"invertY":true,"samplingMode":3,"_useSRGBBuffer":false},"isLocal":true,"animations":[