forked from decentraland/sdk7-goerli-plaza
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
735 additions
and
742 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,69 @@ | ||
import { | ||
Animator, | ||
AudioSource, | ||
ColliderLayer, | ||
engine, | ||
GltfContainer, | ||
InputAction, | ||
pointerEventsSystem, | ||
Transform | ||
Animator, | ||
AudioSource, | ||
ColliderLayer, | ||
engine, | ||
GltfContainer, | ||
InputAction, | ||
pointerEventsSystem, | ||
Transform | ||
} from '@dcl/sdk/ecs' | ||
import { createHummingBird } from './hummingBird' | ||
|
||
export function main() { | ||
const ground = engine.addEntity() | ||
Transform.create(ground, { | ||
position: { x: 8, y: 0, z: 8 }, | ||
rotation: { x: 0, y: 0, z: 0, w: 0 }, | ||
scale: { x: 1.6, y: 1.6, z: 1.6 } | ||
}) | ||
GltfContainer.create(ground, { | ||
src: 'models/Ground.gltf' | ||
}) | ||
const ground = engine.addEntity() | ||
Transform.create(ground, { | ||
position: { x: 8, y: 0, z: 8 }, | ||
rotation: { x: 0, y: 0, z: 0, w: 0 }, | ||
scale: { x: 1.6, y: 1.6, z: 1.6 } | ||
}) | ||
GltfContainer.create(ground, { | ||
src: 'models/Ground.gltf' | ||
}) | ||
|
||
const tree = engine.addEntity() | ||
Transform.create(tree, { | ||
position: { x: 8, y: 0, z: 8 }, | ||
rotation: { x: 0, y: 0, z: 0, w: 0 }, | ||
scale: { x: 1.6, y: 1.6, z: 1.6 } | ||
}) | ||
GltfContainer.create(tree, { | ||
src: 'models/Tree.gltf', | ||
visibleMeshesCollisionMask: ColliderLayer.CL_POINTER, | ||
invisibleMeshesCollisionMask: undefined | ||
}) | ||
const tree = engine.addEntity() | ||
Transform.create(tree, { | ||
position: { x: 8, y: 0, z: 8 }, | ||
rotation: { x: 0, y: 0, z: 0, w: 0 }, | ||
scale: { x: 1.6, y: 1.6, z: 1.6 } | ||
}) | ||
GltfContainer.create(tree, { | ||
src: 'models/Tree.gltf', | ||
visibleMeshesCollisionMask: ColliderLayer.CL_POINTER, | ||
invisibleMeshesCollisionMask: undefined | ||
}) | ||
|
||
AudioSource.create(tree, { | ||
audioClipUrl: 'sounds/pickUp.mp3', | ||
loop: false, | ||
playing: false | ||
}) | ||
AudioSource.create(tree, { | ||
audioClipUrl: 'sounds/pickUp.mp3', | ||
loop: false, | ||
playing: false | ||
}) | ||
|
||
Animator.create(tree, { | ||
states: [ | ||
{ | ||
clip: 'Tree_Action', | ||
loop: false, | ||
playing: false, | ||
shouldReset: true, | ||
name: 'Tree_Action' | ||
} | ||
] | ||
}) | ||
Animator.create(tree, { | ||
states: [ | ||
{ | ||
clip: 'Tree_Action', | ||
loop: false, | ||
playing: false, | ||
shouldReset: true | ||
} | ||
] | ||
}) | ||
|
||
pointerEventsSystem.onPointerDown( | ||
{ | ||
entity: tree, | ||
opts: { | ||
button: InputAction.IA_PRIMARY, | ||
hoverText: 'Shake' | ||
} | ||
}, | ||
function () { | ||
createHummingBird() | ||
const anim = Animator.getMutable(tree) | ||
anim.states[0].playing = true | ||
const audioSource = AudioSource.getMutable(tree) | ||
audioSource.playing = true | ||
} | ||
) | ||
pointerEventsSystem.onPointerDown( | ||
{ | ||
entity: tree, | ||
opts: { | ||
button: InputAction.IA_PRIMARY, | ||
hoverText: 'Shake' | ||
} | ||
}, | ||
function () { | ||
createHummingBird() | ||
const anim = Animator.getMutable(tree) | ||
anim.states[0].playing = true | ||
const audioSource = AudioSource.getMutable(tree) | ||
audioSource.playing = true | ||
} | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,66 @@ | ||
import { | ||
Animator, | ||
ColliderLayer, | ||
engine, | ||
GltfContainer, | ||
InputAction, | ||
pointerEventsSystem, | ||
Transform | ||
Animator, | ||
ColliderLayer, | ||
engine, | ||
GltfContainer, | ||
InputAction, | ||
pointerEventsSystem, | ||
Transform | ||
} from '@dcl/sdk/ecs' | ||
import { Vector3 } from '@dcl/sdk/math' | ||
|
||
export function main() { | ||
const seaBed = engine.addEntity() | ||
const seaBed = engine.addEntity() | ||
|
||
Transform.create(seaBed, { | ||
position: Vector3.create(8, 0, 8), | ||
scale: Vector3.create(0.8, 0.8, 0.8) | ||
}) | ||
Transform.create(seaBed, { | ||
position: Vector3.create(8, 0, 8), | ||
scale: Vector3.create(0.8, 0.8, 0.8) | ||
}) | ||
|
||
GltfContainer.create(seaBed, { | ||
src: 'models/Underwater.gltf' | ||
}) | ||
GltfContainer.create(seaBed, { | ||
src: 'models/Underwater.gltf' | ||
}) | ||
|
||
const shark = engine.addEntity() | ||
const shark = engine.addEntity() | ||
|
||
Transform.create(shark, { | ||
position: Vector3.create(8, 3, 8) | ||
}) | ||
Transform.create(shark, { | ||
position: Vector3.create(8, 3, 8) | ||
}) | ||
|
||
GltfContainer.create(shark, { | ||
src: 'models/shark.glb', | ||
visibleMeshesCollisionMask: ColliderLayer.CL_POINTER, | ||
invisibleMeshesCollisionMask: undefined | ||
}) | ||
GltfContainer.create(shark, { | ||
src: 'models/shark.glb', | ||
visibleMeshesCollisionMask: ColliderLayer.CL_POINTER, | ||
invisibleMeshesCollisionMask: undefined | ||
}) | ||
|
||
Animator.create(shark, { | ||
states: [ | ||
{ | ||
clip: 'swim', | ||
name: 'swim', | ||
playing: true, | ||
loop: true | ||
}, | ||
{ | ||
clip: 'bite', | ||
name: 'bite', | ||
playing: false, | ||
loop: false, | ||
shouldReset: true | ||
} | ||
] | ||
}) | ||
Animator.create(shark, { | ||
states: [ | ||
{ | ||
clip: 'swim', | ||
playing: true, | ||
loop: true | ||
}, | ||
{ | ||
clip: 'bite', | ||
playing: false, | ||
loop: false, | ||
shouldReset: true | ||
} | ||
] | ||
}) | ||
|
||
pointerEventsSystem.onPointerDown( | ||
{ | ||
entity: shark, | ||
opts: { | ||
button: InputAction.IA_POINTER, | ||
hoverText: 'Bite' | ||
} | ||
}, | ||
() => { | ||
// TODO use Animator.getClip() | ||
const mutableAnimator = Animator.getMutable(shark) | ||
mutableAnimator.states[1].playing = true | ||
} | ||
) | ||
pointerEventsSystem.onPointerDown( | ||
{ | ||
entity: shark, | ||
opts: { | ||
button: InputAction.IA_POINTER, | ||
hoverText: 'Bite' | ||
} | ||
}, | ||
() => { | ||
// TODO use Animator.getClip() | ||
const mutableAnimator = Animator.getMutable(shark) | ||
mutableAnimator.states[1].playing = true | ||
} | ||
) | ||
} |
Oops, something went wrong.