diff --git a/src/app.ts b/src/app.ts index a5e1ef3..06bb29b 100644 --- a/src/app.ts +++ b/src/app.ts @@ -3,6 +3,7 @@ import { BitGrid, BitWorld } from "@ca-ts/algo/bit"; import { $autoRandom } from "./bind"; import { createTemplateCell } from "./lib/cell"; import { setRLE } from "./lib/setRLE"; +import { randomId } from "./lib/randomId"; const stackHeight = 1; @@ -80,7 +81,7 @@ export class App { // セルのインスタンスを作成 const instance = this.meshPool.pop() ?? - this.templateMesh.createInstance(`cell_${crypto.randomUUID()}`); + this.templateMesh.createInstance(`cell_${randomId()}`); instance.isVisible = true; instance.position = new BABYLON.Vector3( x, diff --git a/src/lib/randomId.ts b/src/lib/randomId.ts new file mode 100644 index 0000000..0ea9ef0 --- /dev/null +++ b/src/lib/randomId.ts @@ -0,0 +1,4 @@ +export function randomId() { + // httpで使用できない場合 + return crypto.randomUUID ? crypto.randomUUID() : Math.random().toString(16); +}