From aa4a0d6699c7310909ca3ade6756a5dc8686b0b6 Mon Sep 17 00:00:00 2001 From: dinomut1 Date: Mon, 29 Jan 2024 17:24:09 -0500 Subject: [PATCH] update to new codebase --- src/components/BubbleComponent.ts | 22 +++++++++----------- src/components/BubbleEmitterComponent.ts | 26 +++++++++++------------- src/systems/BubbleSystem.ts | 14 +++++-------- 3 files changed, 27 insertions(+), 35 deletions(-) diff --git a/src/components/BubbleComponent.ts b/src/components/BubbleComponent.ts index e171d6f..fff1dc1 100644 --- a/src/components/BubbleComponent.ts +++ b/src/components/BubbleComponent.ts @@ -1,16 +1,14 @@ -import { defineComponent, getComponent, setComponent, useComponent } from "@etherealengine/engine/src/ecs/functions/ComponentFunctions" -import { createEntity, useEntityContext } from "@etherealengine/engine/src/ecs/functions/EntityFunctions" -import { Color, MathUtils, Mesh, MeshStandardMaterial, SphereGeometry, Vector3 } from "three" -import { useEffect } from "react" -import { addObjectToGroup } from "@etherealengine/engine/src/scene/components/GroupComponent" -import { Entity } from "@etherealengine/engine/src/ecs/classes/Entity" -import { NameComponent } from "@etherealengine/engine/src/scene/components/NameComponent" -import { EntityUUID } from "@etherealengine/common/src/interfaces/EntityUUID" -import { EntityTreeComponent } from "@etherealengine/engine/src/ecs/functions/EntityTree" -import { VisibleComponent } from "@etherealengine/engine/src/scene/components/VisibleComponent" -import { LocalTransformComponent } from "@etherealengine/engine/src/transform/components/TransformComponent" + +import { defineComponent, useEntityContext, setComponent } from "@etherealengine/ecs" +import { NameComponent } from "@etherealengine/engine/src/common/NameComponent" +import { addObjectToGroup } from "@etherealengine/engine/src/renderer/components/GroupComponent" +import { VisibleComponent } from "@etherealengine/engine/src/renderer/components/VisibleComponent" +import { Mesh, SphereGeometry, MeshStandardMaterial, Color } from "three" import matches from "ts-matches" +import React, { useEffect } from "react" +import { TransformComponent } from "@etherealengine/engine/src/transform/components/TransformComponent" + export const BubbleComponent = defineComponent({ //name: The human-readable label for the component. This will be displayed in the editor and debugging tools. name: "Bubble Component", @@ -44,7 +42,7 @@ export const BubbleComponent = defineComponent({ useEffect(() => { setComponent(entity, VisibleComponent) // Set if the entity is visible setComponent(entity, NameComponent, "Bubble") // Give the entity a name - setComponent(entity, LocalTransformComponent) // Give the entity a local transform + setComponent(entity, TransformComponent) // Give the entity a local transform const bubbleMesh = new Mesh(new SphereGeometry(), new MeshStandardMaterial()) bubbleMesh.material.color = new Color(0xFFFFFF) addObjectToGroup(entity, bubbleMesh) // Add GroupComponent and add mesh to Group diff --git a/src/components/BubbleEmitterComponent.ts b/src/components/BubbleEmitterComponent.ts index 51f327c..598af46 100644 --- a/src/components/BubbleEmitterComponent.ts +++ b/src/components/BubbleEmitterComponent.ts @@ -1,18 +1,15 @@ -import { defineComponent, getComponent, getMutableComponent, setComponent, useComponent } from "@etherealengine/engine/src/ecs/functions/ComponentFunctions" -import { createEntity, removeEntity, useEntityContext } from "@etherealengine/engine/src/ecs/functions/EntityFunctions" -import { BufferGeometry, Color, MathUtils, Mesh, MeshStandardMaterial, SphereGeometry, Vector3 } from "three" -import { useEffect } from "react" -import { GroupComponent, addObjectToGroup } from "@etherealengine/engine/src/scene/components/GroupComponent" -import { Entity } from "@etherealengine/engine/src/ecs/classes/Entity" -import { NameComponent } from "@etherealengine/engine/src/scene/components/NameComponent" import { EntityUUID } from "@etherealengine/common/src/interfaces/EntityUUID" -import { EntityTreeComponent } from "@etherealengine/engine/src/ecs/functions/EntityTree" -import { VisibleComponent } from "@etherealengine/engine/src/scene/components/VisibleComponent" +import { defineComponent, Entity, useEntityContext, useComponent, removeEntity, getComponent, useExecute, createEntity, setComponent, SimulationSystemGroup, getMutableComponent } from "@etherealengine/ecs" +import { EngineState } from "@etherealengine/engine/src/EngineState" +import { GroupComponent } from "@etherealengine/engine/src/renderer/components/GroupComponent" +import { EntityTreeComponent } from "@etherealengine/engine/src/transform/components/EntityTree" +import { getState, NO_PROXY } from "@etherealengine/hyperflux" +import { Color, Vector3, Mesh, BufferGeometry, MeshStandardMaterial, MathUtils } from "three" import { BubbleComponent } from "./BubbleComponent" -import { NO_PROXY, getState } from "@etherealengine/hyperflux" -import { useExecute } from "@etherealengine/engine/src/ecs/functions/SystemFunctions" -import { SimulationSystemGroup } from "@etherealengine/engine/src/ecs/functions/EngineFunctions" -import { EngineState } from "@etherealengine/engine/src/ecs/classes/EngineState" + +import React, { useEffect } from "react" +import { ECSState } from "@etherealengine/ecs/src/ECSState" + export const BubbleEmitterComponent = defineComponent({ //name: The human-readable label for the component. This will be displayed in the editor and debugging tools. @@ -85,7 +82,8 @@ export const BubbleEmitterComponent = defineComponent({ // Systems will run once per frame // You must explicitly say where you want your system to run(i.e. after SimulationSystemGroup) useExecute(() => { - const { elapsedSeconds, deltaSeconds } = getState(EngineState) + + const deltaSeconds = getState(ECSState).deltaSeconds ageEmitterBubbles(entity, deltaSeconds) // This function is accumulating the age of every bubble with the time from deltaSeconds. // deltaSeconds is the time since the last system execute occured diff --git a/src/systems/BubbleSystem.ts b/src/systems/BubbleSystem.ts index 21e6557..bd5907d 100644 --- a/src/systems/BubbleSystem.ts +++ b/src/systems/BubbleSystem.ts @@ -1,11 +1,7 @@ -import { defineQuery, getComponent, getMutableComponent } from "@etherealengine/engine/src/ecs/functions/ComponentFunctions"; -import { defineSystem } from "@etherealengine/engine/src/ecs/functions/SystemFunctions"; -import { BubbleEmitterComponent, removeBubble } from "../components/BubbleEmitterComponent"; -import { LocalTransformComponent } from "@etherealengine/engine/src/transform/components/TransformComponent"; -import { NO_PROXY, getState } from "@etherealengine/hyperflux"; -import { EngineState } from "@etherealengine/engine/src/ecs/classes/EngineState"; -import { Vector3 } from "three"; -import { SimulationSystemGroup } from "@etherealengine/engine/src/ecs/functions/EngineFunctions"; +import { defineQuery, defineSystem, SimulationSystemGroup, getComponent } from "@etherealengine/ecs" +import { Vector3 } from "three" +import { BubbleEmitterComponent } from "../components/BubbleEmitterComponent" +import { TransformComponent } from "@etherealengine/engine/src/transform/components/TransformComponent" const bubbleEmitterQuery = defineQuery([BubbleEmitterComponent]) const velocity = new Vector3(0,0,0) @@ -18,7 +14,7 @@ export const BubbleSystem = defineSystem({ // [Exercise 2]: Using the below basic setup. Move every bubble not just the first one const tempvector = new Vector3(0,0,0) const emitterComponent = getComponent(entity, BubbleEmitterComponent) - const localTransform = getComponent(emitterComponent.bubbleEntities![0], LocalTransformComponent) + const localTransform = getComponent(emitterComponent.bubbleEntities![0], TransformComponent) if(!localTransform) continue; velocity.copy(emitterComponent.direction).multiplyScalar(emitterComponent.speed) tempvector.addVectors(localTransform.position, velocity)