Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private async started() {
// Create a new actor with no mesh, but some text. This operation is asynchronous, so
// it returns a "forward" promise (a special promise, as we'll see later).
const textAnchorPromise = Actor.CreateEmpty(this.context, {
actor: {
name: 'TextAnchor',
transform: {
app: { position: { x: 0, y: 1.2, z: 0 } }
},
}
});
this.textAnchor = textAnchorPromise.value;
const textPromise = Actor.CreateEmpty(this.context, {
actor: {
parentId: this.textAnchor.id,
name: 'Text',
transform: {
local: { position: { x: 0, y: 0.0, z: -1.5 } }
},
text: {
contents: "Tic-Tac-Toe!",
anchor: TextAnchorLocation.MiddleCenter,
color: { r: 30 / 255, g: 206 / 255, b: 213 / 255 },
height: 0.3
},
}
});
const lightPromise = Actor.CreateEmpty(this.context, {
actor: {
private started() {
// Create a new actor with no mesh, but some text. This operation is asynchronous, so
// it returns a "forward" promise (a special promise, as we'll see later).
const textPromise = Actor.CreateEmpty(this.context, {
actor: {
name: 'Text',
transform: {
position: { x: 0, y: 0.5, z: 0 }
},
text: {
contents: "Hello World!",
anchor: TextAnchorLocation.MiddleCenter,
color: { r: 30 / 255, g: 206 / 255, b: 213 / 255 },
height: 0.3
}
}
});
// Even though the actor is not yet created in Altspace (because we didn't wait for the promise),
// we can still get a reference to it by grabbing the `value` field from the forward promise.
private createRootObject() {
// Create a root actor everything gets parented to. Offset from origin so the chess board
// is centered on it.
this.sceneRoot = Actor.CreateEmpty(
this.context, {
actor: {
transform: {
local: {
scale: appScale
}
}
}
});
return this.sceneRoot.created();
}
private started() {
// Create a new actor with no mesh, but some text. This operation is asynchronous, so
// it returns a "forward" promise (a special promise, as we'll see later).
const textPromise = Actor.CreateEmpty(this.context, {
actor: {
name: 'Text',
transform: {
app: { position: { x: 0, y: 0.5, z: 0 } }
},
text: {
contents: "Hello World!",
anchor: TextAnchorLocation.MiddleCenter,
color: { r: 30 / 255, g: 206 / 255, b: 213 / 255 },
height: 0.3
}
}
});
// Even though the actor is not yet created in Altspace (because we didn't wait for the promise),
// we can still get a reference to it by grabbing the `value` field from the forward promise.
name: "board-offset",
parentId: this.sceneRoot.id,
transform: {
local: {
position: { x: 0.135, z: 0.135 }
}
}
}
});
loads.push(this.boardOffset.created());
const status = this.game.getStatus() as Status;
for (const file of ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']) {
for (const rank of [1, 2, 3, 4, 5, 6, 7, 8]) {
const position = this.coordinate({ file, rank });
const actor = Actor.CreateEmpty(this.context, {
actor: {
name: `square-${file}${rank}`,
parentId: this.boardOffset.id,
transform: { local: { position } },
subscriptions: ['transform']
}
});
loads.push(actor.created());
const squareActor = actor as any as SquareActor;
squareActor.file = file;
squareActor.rank = rank;
const square = status.board.squares.filter(item => item.file === file && item.rank === rank).shift();
square.actor = squareActor;
}
const textPromise = Actor.CreateEmpty(this.context, {
actor: {
parentId: this.textAnchor.id,
name: 'Text',
transform: {
local: { position: { x: 0, y: 0.0, z: -1.5 } }
},
text: {
contents: "Tic-Tac-Toe!",
anchor: TextAnchorLocation.MiddleCenter,
color: { r: 30 / 255, g: 206 / 255, b: 213 / 255 },
height: 0.3
},
}
});
const lightPromise = Actor.CreateEmpty(this.context, {
actor: {
parentId: textPromise.value.id,
name: 'Light',
transform: {
local: {
position: { x: 0, y: 1.0, z: -0.5 },
rotation: Quaternion.RotationAxis(Vector3.Left(), -45.0 * DegreesToRadians),
}
},
light: {
color: { r: 1, g: 0.6, b: 0.3 },
type: 'spot',
intensity: 20,
range: 6,
spotAngle: 45 * DegreesToRadians
},