Skip to content

Instantly share code, notes, and snippets.

@flushpot1125
Created July 19, 2020 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flushpot1125/10486c2b58605791e8f6230362b8c315 to your computer and use it in GitHub Desktop.
Save flushpot1125/10486c2b58605791e8f6230362b8c315 to your computer and use it in GitHub Desktop.
import { Node } from "@babylonjs/core";
import {Mesh} from "@babylonjs/core";//自分で追加
/**
* This represents a script that is attached to a node in the editor.
* Available nodes are:
* - Meshes
* - Lights
* - Cameas
* - Transform nodes
*
* You can extend the desired class according to the node type.
* Example:
* export default class MyMesh extends Mesh {
* public onUpdate(): void {
* this.rotation.y += 0.04;
* }
* }
* The functions "onStart" and "onUpdate" are called automatically.
*/
//export default class MyScript extends Node {//ここはコメントアウト
export default class MyScript extends Mesh {//Meshを使うので変更
/**
* Override constructor.
* @warn do not fill.
*/
// @ts-ignore ignoring the super call as we don't want to re-init
private constructor() { }
/**
* Called on the scene starts.
*/
public onStart(): void {
// attachされたオブジェクトのpositionを3,3,1に変更
this.position.set(3,3,1);
console.log("cube position:"+this.position.x+","+this.position.y+","+this.position.z);
}
/**
* Called each frame.
*/
public onUpdate(): void {
this.rotation.y +=1;//1フレームに1回転
// ...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment