Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.