Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

@croquet/worldcore-kernel

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@croquet/worldcore-kernel - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

6

CHANGELOG.md

@@ -7,2 +7,8 @@ # Changelog

## [1.3.1] - 2022-8-12
### Fixed
- Redundant handling of rotation in PM_Smoothed is removed
- The order of invoking services in ViewRoot.update() places PawnManager at the right spot.
- The sayCache mechanism handles throttling better.
- the children structure of a pawn with a child is properly initialized.

@@ -9,0 +15,0 @@ ## [1.3.0] - 2022-6-16

4

package.json
{
"name": "@croquet/worldcore-kernel",
"version": "1.3.0",
"version": "1.3.1",
"description": "3D World Engine for Croquet (minimal install)",

@@ -36,3 +36,3 @@ "keywords": [

},
"gitHead": "d5e33664baaaa1a3a153e0aa3721ad3a17c25dc3"
"gitHead": "6bd054f2e2e4697ac59c60fba97c78b69f41504c"
}

@@ -372,12 +372,2 @@ import { Constants } from "@croquet/croquet";

if (this.isRotating) {
if (q_equals(this._rotation, this.actor.rotation, 0.000001)) {
this._rotation = this.actor.rotation;
this.isRotating = false;
} else {
this._rotation = q_slerp(this._rotation, this.actor.rotation, tug);
}
this.onLocalChanged();
}
if (this.isTranslating) {

@@ -384,0 +374,0 @@ if (v3_equals(this._translation, this.actor.translation, .0001)) {

@@ -15,3 +15,2 @@ /* eslint-disable new-cap */

this.pawns = new Map();
// this.dynamic = new Set();

@@ -21,2 +20,4 @@ const actorManager = this.modelService("ActorManager");

for(const pawn of this.pawns.values()) { pawn.link() }; // recreate child links after all pawns are spawned
this.subscribe("actor", "createActor", this.spawnPawn);

@@ -32,3 +33,7 @@ }

spawnPawn(actor) { if (actor.pawn) new actor.pawn(actor); }
spawnPawn(actor) { if (actor.pawn) {
const p = new actor.pawn(actor);
p.link();}
}
add(pawn) { this.pawns.set(pawn.actor.id, pawn); }

@@ -56,10 +61,14 @@ has(id) { return this.pawns.has(id); }

this._sayCache = {};
// this.sayLast = {};
// this.sayCache ={};
this._actor = actor;
pm.add(this);
this.link();
this.listen("destroyActor", this.destroy);
this.listen("parentSet", this.onParent);
this.init();
}
init() {}
link() { if(this.parent) this.parent.addChild(this); }

@@ -80,24 +89,20 @@ get actor() {return this._actor};

get children() {
if (this.actor.children && !this._children) this.actor.children.forEach(child => { this.addChild(child.id); })
return this._children;
}
addChild(id) {
const child = GetPawn(id);
if (!child) return;
addChild(child) {
if (!this._children) this._children = new Set();
this._children.add(child);
child._parent = this;
}
removeChild(id) {
const child = GetPawn(id);
if (!child) return;
removeChild(child) {
if (this._children) this._children.delete(child);
child._parent = null;
}
onParent(d) {
if (d.o) GetPawn(d.o.id).removeChild(this.actor.id);
if (d.v) GetPawn(d.v.id).addChild(this.actor.id);
if (d.o) {
this._parent = null;
GetPawn(d.o.id).removeChild(this);
}
if(this.parent) this.parent.addChild(this);
}

@@ -107,3 +112,3 @@

if (this.time < this._sayNext[event]) {
this._sayCache[event] = data;
this._sayCache[event] = { data, throttle };
} else {

@@ -116,2 +121,14 @@ this._sayNext[event] = this.time + throttle;

// say(event, data, throttle = 0) {
// if (this.time < (this.sayLast[event] || 0) + throttle) {
// const expire = this.time + throttle;
// this.sayCache[event] = {data, expire};
// } else {
// this.sayLast[event] = this.time;
// this.publish(this.actor.id, event, data);
// this.sayCache[event] = null;
// }
// }
listen(event, callback) {

@@ -147,4 +164,6 @@ this.subscribe(this.actor.id, event, callback);

for (const event in this._sayCache) { // Flushes expired cached events from throttled says
const data = this._sayCache[event];
if (data && time > this._sayNext[event]) {
const cache = this._sayCache[event];
if (cache && time > this._sayNext[event]) {
const { data, throttle } = cache;
this._sayNext[event] = time + throttle;
this._sayCache[event] = null;

@@ -158,5 +177,25 @@ this.publish(this.actor.id, event, data);

// fullUpdate(time, delta) {
// this.preUpdate(time, delta);
// this.update(time, delta);
// this.postUpdate(time, delta);
// for (const event in this.sayCache) { // Flushes expired cached events from throttled says
// const cache = this.sayCache[event];
// // console.log(cache);
// if (cache) {
// console.log("flush");
// this.sayLast[event] = this.time;
// this.publish(this.actor.id, event, cache.data);
// this.sayCache[event] = null;
// // console.log(this.sayCache[event]);
// }
// }
// if (this.children) this.children.forEach(child => child.fullUpdate(time, delta));
// }
}

@@ -95,2 +95,3 @@ import { Model, View, Session } from "@croquet/croquet";

const viewServices = new Map();
let pawnManager;

@@ -118,3 +119,3 @@ export class ViewRoot extends WorldcoreView {

});
new PawnManager();
pawnManager = new PawnManager();
}

@@ -132,6 +133,8 @@

const delta = time1 - time0;
let done = new Set();
let done = new Set();
pawnManager.update(time, delta); // Pawns update before other services
viewServices.forEach(s => {
if (done.has(s)) {return;}
if (s === pawnManager) return;
done.add(s);

@@ -156,6 +159,2 @@ if (s.update) s.update(time, delta);

this.registerViewName(name);
// this.name = name;
// if (!name) console.error("All services must have public names!");
// else if (viewServices.has(name)) console.error("Duplicate service!");
// else viewServices.set(name, this);
}

@@ -162,0 +161,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc