-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement op_value_ref_call for Browser Runtime
- Loading branch information
Showing
8 changed files
with
276 additions
and
164 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,29 +1,46 @@ | ||
let i = 0; | ||
function filterComponentInfos( | ||
infos: ComponentInfo[], | ||
prefix: string | ||
): string[] { | ||
return infos | ||
.filter((info) => info.name.startsWith(prefix)) | ||
.map((info) => info.name.replace(prefix, "")); | ||
} | ||
|
||
type Scoreboard = { | ||
score: number; | ||
extra: ExtraData; | ||
}; | ||
type ExtraData = { | ||
name: string; | ||
}; | ||
const Scoreboard: BevyType<Scoreboard> = { typeName: "headless::Scoreboard" }; | ||
function componentId(name) { | ||
let id = world.components.find((info) => info.name === name); | ||
if (!id) throw new Error(`component id for ${name} not found`); | ||
return id.id; | ||
} | ||
|
||
info("Loaded"); | ||
let firstIteration = true; | ||
function run() { | ||
if (firstIteration) { | ||
firstIteration = false; | ||
|
||
export default { | ||
update() { | ||
if (i == 0) { | ||
info(world.resources); | ||
} | ||
// info("Components: " + world.components.map(info => info.name).join(", ")); | ||
// info("Resources:"); | ||
// info(world.resources.map(info => info.name)); | ||
// info("Resources (headless): " + filterComponentInfos(world.resources, "headless::").join(", ")); | ||
// info("Entitites: " + (world.entities.map(entity => `Entity(${entity.id}v${entity.generation})`).join(", "))); | ||
// info("----------"); | ||
|
||
if (i % 3 == 0) { | ||
let score = world.resource(Scoreboard); | ||
info(score.toString()); | ||
info(score.score); | ||
info(score.extra.name); | ||
let transformId = componentId( | ||
"bevy_transform::components::transform::Transform" | ||
); | ||
|
||
let query = world.query({ | ||
components: [transformId], | ||
}); | ||
let [transform1, transform2] = query.map((item) => item.components[0]); | ||
let [translation1, translation2] = [transform1.translation, transform2.translation]; | ||
|
||
for (const s of [0.0, 0.25, 0.5, 0.75, 1.0]) { | ||
info(translation1.lerp(translation2, s).toString()); | ||
} | ||
} | ||
} | ||
|
||
i++; | ||
}, | ||
export default { | ||
update: run, | ||
}; |
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
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
Oops, something went wrong.