diff --git a/packages/behavior/src/traits/behaved.js b/packages/behavior/src/traits/behaved.js index 8a7d7fd..9f7c05e 100644 --- a/packages/behavior/src/traits/behaved.js +++ b/packages/behavior/src/traits/behaved.js @@ -14,29 +14,29 @@ const STATIC_INTERVAL = 0.25; export default (flecks) => class Behaved extends decorate(Trait) { - #accumulator = 0; + $$accumulator = 0; - #collectives = []; + $$collectives = []; - #context = {}; + $$context = {}; - #currentRoutine = ''; + $$currentRoutine = ''; - #daemons = {}; + $$daemons = {}; - #routines = {}; + $$routines = {}; constructor() { super(); ({ - currentRoutine: this.#currentRoutine, + currentRoutine: this.$$currentRoutine, } = this.constructor.defaultState()); const {Script} = flecks.get('$avocado/resource.resources'); - this.#context = Script.createContext(); + this.$$context = Script.createContext(); } get context() { - return this.#context; + return this.$$context; } static defaultParams() { @@ -58,9 +58,9 @@ export default (flecks) => class Behaved extends decorate(Trait) { destroy() { super.destroy(); - this.#context = {}; - this.#currentRoutine = undefined; - this.#routines = undefined; + this.$$context = {}; + this.$$currentRoutine = undefined; + this.$$routines = undefined; } listeners() { @@ -89,15 +89,15 @@ export default (flecks) => class Behaved extends decorate(Trait) { async load(json) { await super.load(json); const {Script} = flecks.get('$avocado/resource.resources'); - this.#context = Script.createContext({ + this.$$context = Script.createContext({ entity: this.entity, }); const daemons = { ...this.entity.invokeHookReduced('daemons'), ...this.params.daemons, }; - this.#daemons = Object.values(await this.constructor.loadScripts(daemons, this.#context)); - this.#routines = await this.constructor.loadScripts(this.params.routines, this.#context); + this.$$daemons = Object.values(await this.constructor.loadScripts(daemons, this.$$context)); + this.$$routines = await this.constructor.loadScripts(this.params.routines, this.$$context); this.updateCurrentRoutine(this.state.currentRoutine); super.isBehaving = 'web' !== process.env.FLECKS_CORE_BUILD_TARGET; } @@ -114,23 +114,23 @@ export default (flecks) => class Behaved extends decorate(Trait) { tick(elapsed) { if (this.entity.isBehaving) { - this.#accumulator += elapsed; - if (this.#accumulator >= STATIC_INTERVAL) { - for (let i = 0; i < this.#daemons.length; ++i) { - this.#daemons[i].tick(elapsed); + this.$$accumulator += elapsed; + if (this.$$accumulator >= STATIC_INTERVAL) { + for (let i = 0; i < this.$$daemons.length; ++i) { + this.$$daemons[i].tick(elapsed); } - this.#accumulator -= STATIC_INTERVAL; + this.$$accumulator -= STATIC_INTERVAL; } - if (this.#currentRoutine) { - this.#currentRoutine.tick(elapsed); + if (this.$$currentRoutine) { + this.$$currentRoutine.tick(elapsed); } } } updateCurrentRoutine(currentRoutine) { - this.#currentRoutine = this.#routines[currentRoutine]; - if (this.#currentRoutine) { - this.#currentRoutine.reset(); + this.$$currentRoutine = this.$$routines[currentRoutine]; + if (this.$$currentRoutine) { + this.$$currentRoutine.reset(); } super.currentRoutine = currentRoutine; } diff --git a/packages/dialog/src/traits/decorators/initiator.js b/packages/dialog/src/traits/decorators/initiator.js index 2bd33d4..a4bae62 100644 --- a/packages/dialog/src/traits/decorators/initiator.js +++ b/packages/dialog/src/traits/decorators/initiator.js @@ -1,8 +1,8 @@ export default (Trait, flecks) => class DialogInitiator extends Trait { - #open = []; + $$open = []; - #dialogs = []; + $$dialogs = []; acceptPacket(packet) { if ('OpenDialog' === packet.constructor.type) { @@ -11,7 +11,7 @@ export default (Trait, flecks) => class DialogInitiator extends Trait { } cleanPackets() { - this.#dialogs = []; + this.$$dialogs = []; } hooks() { @@ -21,8 +21,8 @@ export default (Trait, flecks) => class DialogInitiator extends Trait { acceptAction: ({action, value}) => { acceptAction({action, value}); if ('Interact' === action && value) { - if (this.#open.length > 0) { - this.#open[0].skip(); + if (this.$$open.length > 0) { + this.$$open[0].skip(); return false; } } @@ -65,17 +65,17 @@ export default (Trait, flecks) => class DialogInitiator extends Trait { }, }, }); - this.#open.push(dialog); + this.$$open.push(dialog); dialog.once('destroying', () => { - const index = this.#open.indexOf(dialog); + const index = this.$$open.indexOf(dialog); if (-1 !== index) { - this.#open.splice(index, 1); + this.$$open.splice(index, 1); } }); this.entity.list.addEntity(dialog); } else { - this.#dialogs.push({ + this.$$dialogs.push({ text, }); this.markAsDirty(); @@ -88,7 +88,7 @@ export default (Trait, flecks) => class DialogInitiator extends Trait { packetsFor(informed) { return super.packetsFor(informed).concat( informed === this.entity - ? this.#dialogs.map((dialog) => ['OpenDialog', dialog]) + ? this.$$dialogs.map((dialog) => ['OpenDialog', dialog]) : [], ); } diff --git a/packages/dialog/src/traits/dialog.js b/packages/dialog/src/traits/dialog.js index 3987ec4..04b6bae 100644 --- a/packages/dialog/src/traits/dialog.js +++ b/packages/dialog/src/traits/dialog.js @@ -2,15 +2,15 @@ export default (flecks) => { const {Trait} = flecks.fleck('@avocado/traits'); return class Dialog extends Trait { - #dialog; + $$dialog; - #letters = []; + $$letters = []; - #nextLetter = 0; + $$nextLetter = 0; - #thisLetter = 0; + $$thisLetter = 0; - #words = []; + $$words = []; static defaultParams() { return { @@ -41,14 +41,14 @@ export default (flecks) => { const {text} = this.entity; if (text) { ({ - letters: this.#letters, - words: this.#words, + letters: this.$$letters, + words: this.$$words, } = await flecks.get('$avocado/dialog.parser')( `${text}`, )); - if (this.#letters.length > 0) { + if (this.$$letters.length > 0) { this.showThisLetter(); - this.#words.forEach((word) => { + this.$$words.forEach((word) => { // eslint-disable-next-line no-param-reassign word.parentNode = this.entity.node; }); @@ -61,38 +61,38 @@ export default (flecks) => { return { skip: () => { - if (this.#nextLetter === Infinity) { + if (this.$$nextLetter === Infinity) { this.entity.destroy(); return; } - for (let i = 0; i < this.#letters.length; ++i) { - this.#letters[i].opacity = 1; + for (let i = 0; i < this.$$letters.length; ++i) { + this.$$letters[i].opacity = 1; } - this.#nextLetter = Infinity; + this.$$nextLetter = Infinity; }, }; } showThisLetter() { - const letter = this.#letters[this.#thisLetter]; - this.#nextLetter += letter.rate; + const letter = this.$$letters[this.$$thisLetter]; + this.$$nextLetter += letter.rate; letter.opacity = 1; } tick(elapsed) { if ('web' === process.env.FLECKS_CORE_BUILD_TARGET) { - this.#nextLetter -= elapsed; - if (this.#nextLetter <= 0) { - this.#thisLetter += 1; - if (this.#thisLetter >= this.#letters.length) { - this.#nextLetter = Infinity; + this.$$nextLetter -= elapsed; + if (this.$$nextLetter <= 0) { + this.$$thisLetter += 1; + if (this.$$thisLetter >= this.$$letters.length) { + this.$$nextLetter = Infinity; return; } this.showThisLetter(); } - for (let i = 0; i < this.#words.length; ++i) { - this.#words[i].tick(elapsed); + for (let i = 0; i < this.$$words.length; ++i) { + this.$$words[i].tick(elapsed); } } } diff --git a/packages/entity/src/resources/entity-list.js b/packages/entity/src/resources/entity-list.js index 2e36187..83587b4 100644 --- a/packages/entity/src/resources/entity-list.js +++ b/packages/entity/src/resources/entity-list.js @@ -10,17 +10,17 @@ export default (flecks) => { ); return class EntityList extends decorate(JsonResource) { - #afterDestructionTickers = []; + $$afterDestructionTickers = []; - #entities = {}; + $$entities = {}; - #entityTickers = []; + $$entityTickers = []; - #flatEntities = []; + $$flatEntities = []; - #informedEntities = new Map(); + $$informedEntities = new Map(); - #quadTree = new QuadTree(); + $$quadTree = new QuadTree(); async acceptPacket(packet) { await super.acceptPacket(packet); @@ -38,13 +38,13 @@ export default (flecks) => { async addEntity(entity) { const uuid = entity.instanceUuid; // Already exists? - if (this.#entities[uuid]) { + if (this.$$entities[uuid]) { return; } - this.#entities[uuid] = entity; - this.#flatEntities.push(entity); + this.$$entities[uuid] = entity; + this.$$flatEntities.push(entity); if (entity.hasTickers()) { - this.#entityTickers.push(entity.tick); + this.$$entityTickers.push(entity.tick); } // eslint-disable-next-line no-param-reassign entity.list = this; @@ -52,7 +52,7 @@ export default (flecks) => { entity.once('destroying', () => this.onEntityDestroying(entity)); this.emit('entityAdded', entity); if ('web' !== process.env.FLECKS_CORE_BUILD_TARGET) { - this.#informedEntities.set(entity, []); + this.$$informedEntities.set(entity, []); } this.startSynchronizing(entity); } @@ -63,20 +63,20 @@ export default (flecks) => { destroyEntities() { const promises = []; - for (let i = 0; i < this.#flatEntities.length; i++) { - promises.push(this.#flatEntities[i].destroy()); - this.#flatEntities[i]?.tick(Infinity); + for (let i = 0; i < this.$$flatEntities.length; i++) { + promises.push(this.$$flatEntities[i].destroy()); + this.$$flatEntities[i]?.tick(Infinity); } return Promise.all(promises); } get entities() { - return this.#entities; + return this.$$entities; } findEntity(uuid) { - return uuid in this.#entities - ? this.#entities[uuid] + return uuid in this.$$entities + ? this.$$entities[uuid] : undefined; } @@ -100,7 +100,7 @@ export default (flecks) => { const tickers = entity.invokeHookFlat('afterDestructionTickers'); for (let i = 0; i < tickers.length; i++) { const ticker = tickers[i]; - this.#afterDestructionTickers.push(ticker); + this.$$afterDestructionTickers.push(ticker); } } @@ -109,7 +109,7 @@ export default (flecks) => { const {Entity} = flecks.get('$avocado/resource.resources'); // Visible entities. const {areaToInform} = informed; - const previousVisibleEntities = this.#informedEntities.get(informed); + const previousVisibleEntities = this.$$informedEntities.get(informed); const visibleEntities = this.visibleEntities(areaToInform); for (let i = 0; i < visibleEntities.length; i++) { const entity = visibleEntities[i]; @@ -136,7 +136,7 @@ export default (flecks) => { } } // Send updates. - this.#informedEntities.set(informed, visibleEntities); + this.$$informedEntities.set(informed, visibleEntities); // Send destroys. for (let i = 0; i < previousVisibleEntities.length; i++) { const entity = previousVisibleEntities[i]; @@ -149,33 +149,33 @@ export default (flecks) => { } get quadTree() { - return this.#quadTree; + return this.$$quadTree; } removeEntity(entity) { const uuid = entity.instanceUuid; - if (!(uuid in this.#entities)) { + if (!(uuid in this.$$entities)) { return; } this.stopSynchronizing(entity); if ('web' !== process.env.FLECKS_CORE_BUILD_TARGET) { - this.#informedEntities.delete(entity); + this.$$informedEntities.delete(entity); } // eslint-disable-next-line no-param-reassign entity.list = null; entity.emit('removedFromList', this); - delete this.#entities[uuid]; - this.#flatEntities.splice(this.#flatEntities.indexOf(entity), 1); - const index = this.#entityTickers.indexOf(entity.tick); + delete this.$$entities[uuid]; + this.$$flatEntities.splice(this.$$flatEntities.indexOf(entity), 1); + const index = this.$$entityTickers.indexOf(entity.tick); if (-1 !== index) { - this.#entityTickers.splice(index, 1); + this.$$entityTickers.splice(index, 1); } this.emit('entityRemoved', entity); } tick(elapsed) { // Run after destruction tickers. - if (this.#afterDestructionTickers.length > 0) { + if (this.$$afterDestructionTickers.length > 0) { this.tickAfterDestructionTickers(elapsed); } // Run normal tickers. @@ -184,30 +184,30 @@ export default (flecks) => { tickAfterDestructionTickers(elapsed) { const finishedTickers = []; - for (let i = 0; i < this.#afterDestructionTickers.length; ++i) { - const ticker = this.#afterDestructionTickers[i]; + for (let i = 0; i < this.$$afterDestructionTickers.length; ++i) { + const ticker = this.$$afterDestructionTickers[i]; if (ticker(elapsed)) { finishedTickers.push(ticker); } } for (let i = 0; i < finishedTickers.length; ++i) { const ticker = finishedTickers[i]; - const index = this.#afterDestructionTickers.indexOf(ticker); - this.#afterDestructionTickers.splice(index, 1); + const index = this.$$afterDestructionTickers.indexOf(ticker); + this.$$afterDestructionTickers.splice(index, 1); } } tickEntities(elapsed) { - for (let i = 0; i < this.#entityTickers.length; i++) { - this.#entityTickers[i](elapsed); + for (let i = 0; i < this.$$entityTickers.length; i++) { + this.$$entityTickers[i](elapsed); } } toJSON() { const {Entity} = flecks.get('$avocado/resource.resources'); const json = []; - for (let i = 0; i < this.#flatEntities.length; i++) { - const entity = this.#flatEntities[i]; + for (let i = 0; i < this.$$flatEntities.length; i++) { + const entity = this.$$flatEntities[i]; json.push(Entity.withoutDefaults(entity.toJSON())); } return json; @@ -217,13 +217,13 @@ export default (flecks) => { const {areaToInform} = informed; const visibleEntities = this.visibleEntities(areaToInform); // Mark as notified. - this.#informedEntities.set(informed, visibleEntities); + this.$$informedEntities.set(informed, visibleEntities); return visibleEntities.map((entity) => entity.toNetwork(informed)); } visibleEntities(query) { const entities = []; - const quadTree = this.#quadTree; + const quadTree = this.$$quadTree; const entries = Array.from(quadTree.query(query)); for (let i = 0; i < entries.length; i++) { const [entity] = entries[i]; diff --git a/packages/entity/src/resources/entity.js b/packages/entity/src/resources/entity.js index 8b37edb..2cd7a0c 100644 --- a/packages/entity/src/resources/entity.js +++ b/packages/entity/src/resources/entity.js @@ -24,25 +24,25 @@ export default (flecks) => { ); return class Entity extends decorate(JsonResource) { - #hooks = {}; + $$hooks = {}; - #isDestroying = false; + $$isDestroying = false; - #markedAsDirty = true; + $$markedAsDirty = true; - #originalJson; + $$originalJson; - #tickingPromisesTickers = []; + $$tickingPromisesTickers = []; - #traits = {}; + $$traits = {}; - #traitsFlat = []; + $$traitsFlat = []; - #traitTickers = []; + $$traitTickers = []; - #traitRenderTickers = []; + $$traitRenderTickers = []; - #traitsAcceptingPackets = []; + $$traitsAcceptingPackets = []; constructor() { super(); @@ -66,11 +66,11 @@ export default (flecks) => { addTickingPromise(tickingPromise) { const ticker = tickingPromise.tick.bind(tickingPromise); - this.#tickingPromisesTickers.push(ticker); + this.$$tickingPromisesTickers.push(ticker); return tickingPromise.then(() => { - const index = this.#tickingPromisesTickers.indexOf(ticker); + const index = this.$$tickingPromisesTickers.indexOf(ticker); if (-1 !== index) { - this.#tickingPromisesTickers.splice(index, 1); + this.$$tickingPromisesTickers.splice(index, 1); } }); } @@ -83,11 +83,11 @@ export default (flecks) => { return undefined; } if (this.is(type)) { - await this.#traits[type].load({ + await this.$$traits[type].load({ entity: this, ...json, }); - this.emit('traitAdded', type, this.#traits[type]); + this.emit('traitAdded', type, this.$$traits[type]); return undefined; } // Ensure dependencies. @@ -124,23 +124,23 @@ export default (flecks) => { const hooks = Object.entries(trait.hooks()); for (let i = 0; i < hooks.length; i++) { const [key, fn] = hooks[i]; - this.#hooks[key] = this.#hooks[key] || []; - this.#hooks[key].push({ + this.$$hooks[key] = this.$$hooks[key] || []; + this.$$hooks[key].push({ fn, type, }); } // Track trait. - this.#traits[type] = trait; - this.#traitsFlat.push(trait); + this.$$traits[type] = trait; + this.$$traitsFlat.push(trait); if ('tick' in trait) { - this.#traitTickers.push(trait.tick); + this.$$traitTickers.push(trait.tick); } if ('renderTick' in trait) { - this.#traitRenderTickers.push(trait.renderTick); + this.$$traitRenderTickers.push(trait.renderTick); } if ('acceptPacket' in trait) { - this.#traitsAcceptingPackets.push(trait); + this.$$traitsAcceptingPackets.push(trait); } this.startSynchronizing(trait); this.emit('traitAdded', type, trait); @@ -179,13 +179,13 @@ export default (flecks) => { } cleanPackets() { - if (!this.#markedAsDirty) { + if (!this.$$markedAsDirty) { return; } - for (let i = 0; i < this.#traitsFlat.length; i++) { - this.#traitsFlat[i].cleanPackets(); + for (let i = 0; i < this.$$traitsFlat.length; i++) { + this.$$traitsFlat[i].cleanPackets(); } - this.#markedAsDirty = false; + this.$$markedAsDirty = false; } // TODO: behavior decorator @@ -202,10 +202,10 @@ export default (flecks) => { } async destroy() { - if (this.#isDestroying) { + if (this.$$isDestroying) { return; } - this.#isDestroying = true; + this.$$isDestroying = true; if (module.hot) { hotEntities.delete(this); } @@ -225,15 +225,15 @@ export default (flecks) => { } hasTickers() { - return this.#traitTickers.length; + return this.$$traitTickers.length; } invokeHook(hook, ...args) { const results = {}; - if (!(hook in this.#hooks)) { + if (!(hook in this.$$hooks)) { return results; } - const values = Object.values(this.#hooks[hook]); + const values = Object.values(this.$$hooks[hook]); for (let i = 0; i < values.length; i++) { const {fn, type} = values[i]; results[type] = fastApply(null, fn, args); @@ -251,26 +251,26 @@ export default (flecks) => { } is(type) { - return type in this.#traits; + return type in this.$$traits; } async load(json = {}) { await super.load(json); const {instanceUuid, traits = {}} = json; - if (!this.#originalJson) { - this.#originalJson = json; + if (!this.$$originalJson) { + this.$$originalJson = json; } this.instanceUuid = instanceUuid || this.numericUid; await this.addTraits(traits); } markAsDirty() { - this.#markedAsDirty = true; + this.$$markedAsDirty = true; } packetsFor(informed) { const packets = []; - const traits = Object.values(this.#traits); + const traits = Object.values(this.$$traits); for (let i = 0; i < traits.length; i++) { const trait = traits[i]; const traitPackets = trait.packetsFor(informed); @@ -291,8 +291,8 @@ export default (flecks) => { } renderTick(elapsed) { - for (let i = 0; i < this.#traitRenderTickers.length; i++) { - this.#traitRenderTickers[i](elapsed); + for (let i = 0; i < this.$$traitRenderTickers.length; i++) { + this.$$traitRenderTickers[i](elapsed); } } @@ -307,7 +307,7 @@ export default (flecks) => { return; } // Destroy instance. - const instance = this.#traits[type]; + const instance = this.$$traits[type]; this.stopSynchronizing(instance); // Remove methods, hooks, and properties. const methods = instance.methods(); @@ -318,8 +318,8 @@ export default (flecks) => { const hooks = Object.keys(instance.hooks()); for (let i = 0; i < hooks.length; i++) { const hook = hooks[i]; - const implementation = this.#hooks[hook].find(({type: hookType}) => hookType === type); - this.#hooks[hook].splice(this.#hooks[hook].indexOf(implementation), 1); + const implementation = this.$$hooks[hook].find(({type: hookType}) => hookType === type); + this.$$hooks[hook].splice(this.$$hooks[hook].indexOf(implementation), 1); } const {[type]: Trait} = flecks.get('$avocado/traits.traits'); const properties = enumerateTraitAccessorKeys(Trait.prototype); @@ -335,17 +335,17 @@ export default (flecks) => { } instance.destroy(); // Remove instance. - delete this.#traits[type]; - this.#traitsFlat.splice(this.#traitsFlat.indexOf(instance), 1); + delete this.$$traits[type]; + this.$$traitsFlat.splice(this.$$traitsFlat.indexOf(instance), 1); if ('tick' in instance) { - this.#traitTickers.splice(this.#traitTickers.indexOf(instance.tick), 1); + this.$$traitTickers.splice(this.$$traitTickers.indexOf(instance.tick), 1); } if ('renderTick' in instance) { - this.#traitRenderTickers.splice(this.#traitRenderTickers.indexOf(instance.renderTick), 1); + this.$$traitRenderTickers.splice(this.$$traitRenderTickers.indexOf(instance.renderTick), 1); } - const acceptPacketIndex = this.#traitsAcceptingPackets.indexOf(instance); + const acceptPacketIndex = this.$$traitsAcceptingPackets.indexOf(instance); if (-1 !== acceptPacketIndex) { - this.#traitsAcceptingPackets.splice(acceptPacketIndex, 1); + this.$$traitsAcceptingPackets.splice(acceptPacketIndex, 1); } // Unloop. instance.entity = undefined; @@ -362,11 +362,11 @@ export default (flecks) => { tick(elapsed) { this.elapsed = elapsed; this.uptime += elapsed; - for (let i = 0; i < this.#traitTickers.length; i++) { - this.#traitTickers[i](elapsed); + for (let i = 0; i < this.$$traitTickers.length; i++) { + this.$$traitTickers[i](elapsed); } - for (let i = 0; i < this.#tickingPromisesTickers.length; i++) { - this.#tickingPromisesTickers[i](elapsed); + for (let i = 0; i < this.$$tickingPromisesTickers.length; i++) { + this.$$tickingPromisesTickers[i](elapsed); } } @@ -375,12 +375,12 @@ export default (flecks) => { if (this.uri) { const pristine = {}; const json = {}; - const traits = Object.entries(this.#traits); + const traits = Object.entries(this.$$traits); for (let i = 0; i < traits.length; i++) { const [type, trait] = traits[i]; pristine.traits = pristine.traits || {}; pristine.traits[type] = trait.constructor.withDefaults( - this.#originalJson ? this.#originalJson.traits[type] : {}, + this.$$originalJson ? this.$$originalJson.traits[type] : {}, ); json.traits = json.traits || {}; json.traits[type] = trait.toJSON(); @@ -392,7 +392,7 @@ export default (flecks) => { } else { output = {}; - const traits = Object.entries(this.#traits); + const traits = Object.entries(this.$$traits); for (let i = 0; i < traits.length; i++) { const [type, trait] = traits[i]; output.traits = {}; @@ -409,11 +409,11 @@ export default (flecks) => { const json = { traits: {}, }; - const traits = Object.entries(this.#traits); + const traits = Object.entries(this.$$traits); for (let i = 0; i < traits.length; i++) { const [type, trait] = traits[i]; pristine.traits[type] = trait.constructor.withDefaults( - this.#originalJson ? this.#originalJson.traits[type] : {}, + this.$$originalJson ? this.$$originalJson.traits[type] : {}, ); json.traits[type] = trait.toNetwork(informed); } @@ -432,15 +432,15 @@ export default (flecks) => { } trait(type) { - return this.#traits[type]; + return this.$$traits[type]; } get traits() { - return this.#traits; + return this.$$traits; } traitTypes() { - return Object.keys(this.#traits); + return Object.keys(this.$$traits); } static withDefaults(json = {}) { diff --git a/packages/entity/src/traits/alive.js b/packages/entity/src/traits/alive.js index 44774e2..60b616b 100644 --- a/packages/entity/src/traits/alive.js +++ b/packages/entity/src/traits/alive.js @@ -13,13 +13,13 @@ const decorate = compose( export default (flecks) => class Alive extends decorate(Trait) { - #deathCheck; + $$deathCheck; - #hasDied = false; + $$hasDied = false; - #isDying = false; + $$isDying = false; - #packets = []; + $$packets = []; acceptPacket(packet) { switch (packet.constructor.type) { @@ -36,7 +36,7 @@ export default (flecks) => class Alive extends decorate(Trait) { cleanPackets() { super.cleanPackets(); - this.#packets = []; + this.$$packets = []; } static defaultParams() { @@ -80,14 +80,14 @@ export default (flecks) => class Alive extends decorate(Trait) { } }, )); - this.#hasDied = true; + this.$$hasDied = true; this.entity.destroy(); } hooks() { return { - destroy: () => () => (this.#isDying ? this.#hasDied : true), + destroy: () => () => (this.$$isDying ? this.$$hasDied : true), }; } @@ -105,7 +105,7 @@ export default (flecks) => class Alive extends decorate(Trait) { return { startedDying: () => { - this.#packets.push(['Died']); + this.$$packets.push(['Died']); }, tookHarm: (harm) => { @@ -118,7 +118,7 @@ export default (flecks) => class Alive extends decorate(Trait) { async load(json) { await super.load(json); const {Script} = flecks.get('$avocado/resource.resources'); - this.#deathCheck = await Script.load(this.params.deathCheck, this.entity.contextOrDefault); + this.$$deathCheck = await Script.load(this.params.deathCheck, this.entity.contextOrDefault); } get maxLife() { @@ -134,17 +134,17 @@ export default (flecks) => class Alive extends decorate(Trait) { return { die: () => { - if (!this.#isDying) { - this.#isDying = this.die(); + if (!this.$$isDying) { + this.$$isDying = this.die(); } - return this.#isDying; + return this.$$isDying; }, }; } packetsFor() { - const packets = this.#packets.concat(); + const packets = this.$$packets.concat(); const {life, maxLife} = this.stateDifferences(); if (life || maxLife) { packets.push([ @@ -160,8 +160,8 @@ export default (flecks) => class Alive extends decorate(Trait) { tick() { if ('web' !== process.env.FLECKS_CORE_BUILD_TARGET) { - if (!this.#isDying) { - this.#deathCheck.evaluate(({value: died}) => { + if (!this.$$isDying) { + this.$$deathCheck.evaluate(({value: died}) => { if (died) { this.entity.die(); } diff --git a/packages/entity/src/traits/dom-node.js b/packages/entity/src/traits/dom-node.js index 756ddbd..23318aa 100644 --- a/packages/entity/src/traits/dom-node.js +++ b/packages/entity/src/traits/dom-node.js @@ -16,7 +16,7 @@ const decorate = compose( export default () => class DomNode extends decorate(Trait) { - #scheduledRuleApplication = true; + $$scheduledRuleApplication = true; static defaultParams() { return { @@ -51,31 +51,31 @@ export default () => class DomNode extends decorate(Trait) { return { opacityChanged: () => { - this.#scheduledRuleApplication = true; + this.$$scheduledRuleApplication = true; }, positionChanged: () => { - this.#scheduledRuleApplication = true; + this.$$scheduledRuleApplication = true; }, rotationChanged: () => { - this.#scheduledRuleApplication = true; + this.$$scheduledRuleApplication = true; }, textChanged: () => { - this.#scheduledRuleApplication = true; + this.$$scheduledRuleApplication = true; }, visibleScaleChanged: () => { - this.#scheduledRuleApplication = true; + this.$$scheduledRuleApplication = true; }, domScaleXChanged: () => { - this.#scheduledRuleApplication = true; + this.$$scheduledRuleApplication = true; }, domScaleYChanged: () => { - this.#scheduledRuleApplication = true; + this.$$scheduledRuleApplication = true; }, parentNodeChanged: (oldParentNode, newParentNode) => { @@ -114,8 +114,8 @@ export default () => class DomNode extends decorate(Trait) { } tick() { - if ('web' === process.env.FLECKS_CORE_BUILD_TARGET && this.#scheduledRuleApplication) { - this.#scheduledRuleApplication = false; + if ('web' === process.env.FLECKS_CORE_BUILD_TARGET && this.$$scheduledRuleApplication) { + this.$$scheduledRuleApplication = false; this.applyStyleRules(); } } diff --git a/packages/entity/src/traits/dom-text.js b/packages/entity/src/traits/dom-text.js index 16c7d3c..d16a97c 100644 --- a/packages/entity/src/traits/dom-text.js +++ b/packages/entity/src/traits/dom-text.js @@ -2,12 +2,12 @@ import {Trait} from '@avocado/traits'; export default () => class DomText extends Trait { - #text; + $$text; constructor() { super(); if ('web' === process.env.FLECKS_CORE_BUILD_TARGET) { - this.#text = window.document.createElement('span'); + this.$$text = window.document.createElement('span'); } } @@ -48,30 +48,30 @@ export default () => class DomText extends Trait { async load(json) { await super.load(json); - if (!this.#text) { + if (!this.$$text) { return; } const {text} = this.entity; - this.#text.innerText = text; - this.#text.style.position = 'relative'; + this.$$text.innerText = text; + this.$$text.style.position = 'relative'; const {fontSize} = this.params; if (fontSize) { - this.#text.style.fontSize = `${fontSize}px`; + this.$$text.style.fontSize = `${fontSize}px`; if (this.params.centered) { - this.#text.style.left = `-${(fontSize / 2) * text.length}px`; - this.#text.style.top = `-${(fontSize / 2)}px`; + this.$$text.style.left = `-${(fontSize / 2) * text.length}px`; + this.$$text.style.top = `-${(fontSize / 2)}px`; } } - this.entity.node.appendChild(this.#text); + this.entity.node.appendChild(this.$$text); } onColorChanged() { - if (!this.#text) { + if (!this.$$text) { return; } if (this.entity.is('Colorized')) { const {red, green, blue} = this.entity; - this.#text.style.color = `rgb(${red}, ${green}, ${blue})`; + this.$$text.style.color = `rgb(${red}, ${green}, ${blue})`; } } diff --git a/packages/entity/src/traits/mobile.js b/packages/entity/src/traits/mobile.js index 093c669..dfc41f7 100644 --- a/packages/entity/src/traits/mobile.js +++ b/packages/entity/src/traits/mobile.js @@ -16,11 +16,11 @@ const decorate = compose( export default () => class Mobile extends decorate(Trait) { - #appliedMovement = [0, 0]; + $$appliedMovement = [0, 0]; - #movement = [0, 0, 0, 0]; + $$movement = [0, 0, 0, 0]; - #rememberedActionMovement = [0, 0]; + $$rememberedActionMovement = [0, 0]; acceptPacket(packet) { switch (packet.constructor.type) { @@ -51,16 +51,16 @@ export default () => class Mobile extends decorate(Trait) { acceptAction: ({action, value}) => { switch (action) { case 'MoveUp': - this.#movement[0] = value; + this.$$movement[0] = value; break; case 'MoveRight': - this.#movement[1] = value; + this.$$movement[1] = value; break; case 'MoveDown': - this.#movement[2] = value; + this.$$movement[2] = value; break; case 'MoveLeft': - this.#movement[3] = value; + this.$$movement[3] = value; break; default: return; @@ -68,14 +68,14 @@ export default () => class Mobile extends decorate(Trait) { if ('web' === process.env.FLECKS_CORE_BUILD_TARGET) { return; } - this.#rememberedActionMovement = [ - this.#movement[1] - this.#movement[3], - this.#movement[2] - this.#movement[0], + this.$$rememberedActionMovement = [ + this.$$movement[1] - this.$$movement[3], + this.$$movement[2] - this.$$movement[0], ]; if (!this.entity.isAcceptingInput) { return; } - this.setActionMovement(this.#rememberedActionMovement); + this.setActionMovement(this.$$rememberedActionMovement); }, }; @@ -83,18 +83,18 @@ export default () => class Mobile extends decorate(Trait) { hotJSON() { return { - appliedMovement: this.#appliedMovement, - movement: this.#movement, + appliedMovement: this.$$appliedMovement, + movement: this.$$movement, }; } async load(json) { await super.load(json); if (json.appliedMovement) { - this.#appliedMovement = json.appliedMovement; + this.$$appliedMovement = json.appliedMovement; } if (json.movement) { - this.#movement = json.movement; + this.$$movement = json.movement; } } @@ -106,7 +106,7 @@ export default () => class Mobile extends decorate(Trait) { this.setActionMovement([0, 0]); } else { - this.setActionMovement(this.#rememberedActionMovement); + this.setActionMovement(this.$$rememberedActionMovement); } }, @@ -117,7 +117,7 @@ export default () => class Mobile extends decorate(Trait) { return { applyMovement: (vector) => { - this.#appliedMovement = Vector.add(this.#appliedMovement, vector); + this.$$appliedMovement = Vector.add(this.$$appliedMovement, vector); }, forceMovement: (movement) => { @@ -215,19 +215,19 @@ export default () => class Mobile extends decorate(Trait) { if (this.entity.isMobile && !Vector.isZero(this.actionMovement)) { this.entity.requestMovement(this.actionMovement); } - if (Vector.isZero(this.#appliedMovement)) { + if (Vector.isZero(this.$$appliedMovement)) { return; } if (this.entity.is('Physical')) { - this.entity.applyImpulse(this.#appliedMovement); + this.entity.applyImpulse(this.$$appliedMovement); } else { this.entity.forceMovement(Vector.scale( - this.#appliedMovement, + this.$$appliedMovement, elapsed, )); } - this.#appliedMovement = [0, 0]; + this.$$appliedMovement = [0, 0]; } }; diff --git a/packages/entity/src/traits/perishable.js b/packages/entity/src/traits/perishable.js index 9e97d8c..c176d88 100644 --- a/packages/entity/src/traits/perishable.js +++ b/packages/entity/src/traits/perishable.js @@ -6,12 +6,12 @@ const decorate = compose( export default () => class Perishable extends decorate(Trait) { - #ttl = 0; + $$ttl = 0; constructor() { super(); ({ - ttl: this.#ttl, + ttl: this.$$ttl, } = this.constructor.defaultParams()); } @@ -23,12 +23,12 @@ export default () => class Perishable extends decorate(Trait) { async load(json) { await super.load(json); - this.#ttl = this.params.ttl; + this.$$ttl = this.params.ttl; } tick(elapsed) { - this.#ttl -= elapsed; - if (this.#ttl <= 0) { + this.$$ttl -= elapsed; + if (this.$$ttl <= 0) { this.entity.destroy(); } } diff --git a/packages/entity/src/traits/spawner.js b/packages/entity/src/traits/spawner.js index 842517d..4a3db3f 100644 --- a/packages/entity/src/traits/spawner.js +++ b/packages/entity/src/traits/spawner.js @@ -11,16 +11,16 @@ const decorate = compose( export default (flecks) => class Spawner extends decorate(Trait) { - #children; + $$children; - #childrenListeners; + $$childrenListeners; - #spawnJSONs; + $$spawnJSONs; constructor() { super(); - this.#children = []; - this.#childrenListeners = new Map(); + this.$$children = []; + this.$$childrenListeners = new Map(); } // eslint-disable-next-line class-methods-use-this @@ -121,8 +121,8 @@ export default (flecks) => class Spawner extends decorate(Trait) { destroy() { super.destroy(); - while (this.#children.length > 0) { - const child = this.#children.pop(); + while (this.$$children.length > 0) { + const child = this.$$children.pop(); if (child) { this.removeChild(child); } @@ -153,7 +153,7 @@ export default (flecks) => class Spawner extends decorate(Trait) { } maySpawn() { - if (this.maxSpawns > 0 && this.maxSpawns <= this.#children.length) { + if (this.maxSpawns > 0 && this.maxSpawns <= this.$$children.length) { return false; } if (!this.destinationEntityList()) { @@ -168,7 +168,7 @@ export default (flecks) => class Spawner extends decorate(Trait) { killAllChildren: () => { // Juggle children since this may cause splices and mess up the array. const promises = []; - const children = this.#children.slice(0); + const children = this.$$children.slice(0); for (let i = 0; i < children.length; i++) { const child = children[i]; promises.push( @@ -223,15 +223,15 @@ export default (flecks) => class Spawner extends decorate(Trait) { return undefined; } // Add null to children to prevent race. - const childIndex = this.#children.length; - this.#children.push(null); + const childIndex = this.$$children.length; + this.$$children.push(null); const list = this.destinationEntityList(); const {Entity} = flecks.get('$avocado/resource.resources'); const child = await Entity.load(json); - this.#children[childIndex] = child; + this.$$children[childIndex] = child; // Listen for destroy event. const listener = this.removeChild.bind(this, child); - this.#childrenListeners.set(child, listener); + this.$$childrenListeners.set(child, listener); child.once('destroying', listener); // Add child to list. list.addEntity(child); @@ -266,12 +266,12 @@ export default (flecks) => class Spawner extends decorate(Trait) { } removeChild(child) { - const index = this.#children.indexOf(child); + const index = this.$$children.indexOf(child); if (-1 !== index) { - this.#children.splice(index, 1); - const listener = this.#childrenListeners.get(child); + this.$$children.splice(index, 1); + const listener = this.$$childrenListeners.get(child); child.off('destroying', listener); - this.#childrenListeners.delete(child); + this.$$childrenListeners.delete(child); } } diff --git a/packages/graphics/src/atlas.js b/packages/graphics/src/atlas.js index 1d4fa7a..6f5a8b2 100644 --- a/packages/graphics/src/atlas.js +++ b/packages/graphics/src/atlas.js @@ -5,21 +5,21 @@ import Image from './image'; export default class Atlas extends JsonResource { - #image; + $$image; - #size = [0, 0]; + $$size = [0, 0]; - #subimages = []; + $$subimages = []; destroy() { - this.#subimages.forEach((subimage) => { + this.$$subimages.forEach((subimage) => { subimage.destroy(); }); - this.#subimages = []; + this.$$subimages = []; } get image() { - return this.#image; + return this.$$image; } async load(json = {}) { @@ -29,19 +29,19 @@ export default class Atlas extends JsonResource { if (!imageUri) { return; } - this.#image = await Image.load(imageUri); + this.$$image = await Image.load(imageUri); switch (type) { case 'grid': { const {size} = json; if (Vector.isNull(size)) { return; } - const grid = Vector.div(this.#image.size, size); + const grid = Vector.div(this.$$image.size, size); const rectangle = Rectangle.compose([0, 0], size); for (let j = 0; j < grid[1]; ++j) { for (let i = 0; i < grid[0]; ++i) { - const subimage = this.#image.subimage(rectangle); - this.#subimages.push(subimage); + const subimage = this.$$image.subimage(rectangle); + this.$$subimages.push(subimage); rectangle[0] += size[0]; } rectangle[0] = 0; @@ -54,7 +54,7 @@ export default class Atlas extends JsonResource { } subimage(index) { - return this.#subimages[index]; + return this.$$subimages[index]; } } diff --git a/packages/graphics/src/container.js b/packages/graphics/src/container.js index 5206418..584e694 100644 --- a/packages/graphics/src/container.js +++ b/packages/graphics/src/container.js @@ -7,7 +7,7 @@ import Renderable from './renderable'; export default class Container extends Renderable { - #filterMap = {}; + $$filterMap = {}; constructor() { super(); @@ -91,10 +91,10 @@ export default class Container extends Renderable { default: } if (filter) { - if (!this.#filterMap[id]) { - this.#filterMap[id] = {}; + if (!this.$$filterMap[id]) { + this.$$filterMap[id] = {}; } - this.#filterMap[id][type] = filter; + this.$$filterMap[id][type] = filter; if (!this.container.filters) { this.container.filters = []; } @@ -164,7 +164,7 @@ export default class Container extends Renderable { return; } this.container.filters = []; - this.#filterMap = {}; + this.$$filterMap = {}; } removeChild(child) { @@ -188,13 +188,13 @@ export default class Container extends Renderable { if (this.container.isFake) { return; } - if (this.#filterMap[id]?.[type]) { + if (this.$$filterMap[id]?.[type]) { const {filters} = this.container; - const index = filters.indexOf(this.#filterMap[id][type]); + const index = filters.indexOf(this.$$filterMap[id][type]); if (-1 !== index) { filters.splice(index, 1); } - delete this.#filterMap[id][type]; + delete this.$$filterMap[id][type]; } } diff --git a/packages/graphics/src/primitives.js b/packages/graphics/src/primitives.js index 924a91a..83ad9b7 100644 --- a/packages/graphics/src/primitives.js +++ b/packages/graphics/src/primitives.js @@ -34,7 +34,7 @@ export default class Primitives extends Renderable { drawCircle(position, radius, lineStyle, fillStyle) { if (!this.primitives.isFake) { - this.#wrapStyle('drawCircle', '3rd', lineStyle, fillStyle, () => { + this.$$wrapStyle('drawCircle', '3rd', lineStyle, fillStyle, () => { this.primitives.drawCircle(position[0], position[1], radius); }); } @@ -42,7 +42,7 @@ export default class Primitives extends Renderable { drawLine(p1, p2, lineStyle, fillStyle) { if (!this.primitives.isFake) { - this.#wrapStyle('drawLine', '3rd', lineStyle, fillStyle, () => { + this.$$wrapStyle('drawLine', '3rd', lineStyle, fillStyle, () => { this.primitives.moveTo(p1[0] + 0.5, p1[1] + 0.5); this.primitives.lineTo(p2[0] + 0.5, p2[1] + 0.5); }); @@ -58,7 +58,7 @@ export default class Primitives extends Renderable { ]; const p1 = Vector.add(p, [0.5, 0.5]); const p2 = Vector.add(p, Vector.sub(Vector.add(v, shift), sign)); - this.#wrapStyle('drawLine', '3rd', lineStyle, fillStyle, () => { + this.$$wrapStyle('drawLine', '3rd', lineStyle, fillStyle, () => { this.primitives.moveTo(p1[0], p1[1]); this.primitives.lineTo(p2[0], p2[1]); }); @@ -71,14 +71,14 @@ export default class Primitives extends Renderable { const [x, y] = vertices[i]; ps.push(x, y); } - this.#wrapStyle('drawLine', '2nd', lineStyle, fillStyle, () => { + this.$$wrapStyle('drawLine', '2nd', lineStyle, fillStyle, () => { this.primitives.drawPolygon(ps); }); } drawRectangle(rectangle, lineStyle, fillStyle) { if (!this.primitives.isFake) { - this.#wrapStyle('drawLine', '2nd', lineStyle, fillStyle, () => { + this.$$wrapStyle('drawLine', '2nd', lineStyle, fillStyle, () => { this.primitives.drawRect( rectangle[0], rectangle[1], @@ -93,7 +93,7 @@ export default class Primitives extends Renderable { return this.primitives; } - #wrapStyle(method, where, lineStyle, fillStyle, fn) { + $$wrapStyle(method, where, lineStyle, fillStyle, fn) { if (!lineStyle) { throw new TypeError(`Primitives::${method} expects lineStyle as ${where} parameter`); } diff --git a/packages/graphics/src/traits/pictured.js b/packages/graphics/src/traits/pictured.js index 9c1cd75..7e9fa51 100644 --- a/packages/graphics/src/traits/pictured.js +++ b/packages/graphics/src/traits/pictured.js @@ -16,17 +16,17 @@ export default (flecks) => { return class Pictured extends decorate(Trait) { - #currentImage = ''; + $$currentImage = ''; - #images = {}; + $$images = {}; - #sprites = {}; + $$sprites = {}; constructor() { super(); this.$$cachedAabbs = {}; ({ - currentImage: this.#currentImage, + currentImage: this.$$currentImage, } = this.constructor.defaultState()); } @@ -50,15 +50,15 @@ export default (flecks) => { destroy() { super.destroy(); - if (this.#sprites) { - const sprites = Object.entries(this.#sprites); + if (this.$$sprites) { + const sprites = Object.entries(this.$$sprites); for (let i = 0; i < sprites.length; i++) { const [key, sprite] = sprites[i]; this.hideImage(key); sprite.image.destroy(); sprite.destroy(); } - this.#sprites = undefined; + this.$$sprites = undefined; } } @@ -66,10 +66,10 @@ export default (flecks) => { if (!this.entity.container) { return; } - if (!this.#sprites) { + if (!this.$$sprites) { return; } - const sprite = this.#sprites[key]; + const sprite = this.$$sprites[key]; if (!sprite) { return; } @@ -80,14 +80,14 @@ export default (flecks) => { return { visibleAabbs: () => { - const key = this.#currentImage; + const key = this.$$currentImage; if (this.$$cachedAabbs[key]) { return this.$$cachedAabbs[key]; } - if (!this.#images[key]) { + if (!this.$$images[key]) { return [0, 0, 0, 0]; } - const {size} = this.#images[key]; + const {size} = this.$$images[key]; if (Vector.isZero(size)) { return [0, 0, 0, 0]; } @@ -112,7 +112,7 @@ export default (flecks) => { return { currentImageChanged: (oldKey, currentImage) => { - this.#currentImage = currentImage; + this.$$currentImage = currentImage; this.entity.scheduleBoundingBoxUpdate(); this.hideImage(oldKey); this.showImage(currentImage); @@ -123,8 +123,8 @@ export default (flecks) => { }, traitAdded: () => { - Object.keys(this.#sprites).forEach((key) => { - this[`${key === this.#currentImage ? 'show' : 'hide'}Image`](key); + Object.keys(this.$$sprites).forEach((key) => { + this[`${key === this.$$currentImage ? 'show' : 'hide'}Image`](key); }); this.setSpriteScale(); this.entity.forceBoundingBoxUpdate(); @@ -145,19 +145,19 @@ export default (flecks) => { }) .filter(([, {uri}]) => !!uri), ); - this.#currentImage = this.state.currentImage; - this.#images = await mapValuesAsync(images, ({uri}) => Image.load(uri)); - this.#sprites = await mapValuesAsync(this.#images, async (image) => new Sprite(image)); - Object.keys(this.#sprites).forEach((key) => { + this.$$currentImage = this.state.currentImage; + this.$$images = await mapValuesAsync(images, ({uri}) => Image.load(uri)); + this.$$sprites = await mapValuesAsync(this.$$images, async (image) => new Sprite(image)); + Object.keys(this.$$sprites).forEach((key) => { // eslint-disable-next-line no-param-reassign - this.#sprites[key].position = this.offsetFor(key); + this.$$sprites[key].position = this.offsetFor(key); }); } methods() { return { - image: (key) => this.#sprites[key]?.image, + image: (key) => this.$$sprites[key]?.image, }; } @@ -170,11 +170,11 @@ export default (flecks) => { } setSpriteScale() { - if (!this.#sprites) { + if (!this.$$sprites) { return; } const {visibleScale} = this.entity; - const sprites = Object.values(this.#sprites); + const sprites = Object.values(this.$$sprites); for (let i = 0; i < sprites.length; i++) { sprites[i].scale = visibleScale; } @@ -184,10 +184,10 @@ export default (flecks) => { if (!this.entity.container) { return; } - if (!this.#sprites) { + if (!this.$$sprites) { return; } - const sprite = this.#sprites[key]; + const sprite = this.$$sprites[key]; if (!sprite) { return; } diff --git a/packages/graphics/src/traits/primitive.js b/packages/graphics/src/traits/primitive.js index e7db5ba..4774e22 100644 --- a/packages/graphics/src/traits/primitive.js +++ b/packages/graphics/src/traits/primitive.js @@ -6,9 +6,9 @@ export default (flecks) => { return class Primitive extends Trait { - #primitives; + $$primitives; - #scheduledDraw = true; + $$scheduledDraw = true; static defaultParams() { return { @@ -23,9 +23,9 @@ export default (flecks) => { } destroy() { - if (this.#primitives) { - this.#primitives.destroy(); - this.#primitives = undefined; + if (this.$$primitives) { + this.$$primitives.destroy(); + this.$$primitives = undefined; } } @@ -33,12 +33,12 @@ export default (flecks) => { if (!this.entity.container) { return; } - if (this.#primitives) { - this.#primitives.clear(); + if (this.$$primitives) { + this.$$primitives.clear(); } else { - this.#primitives = new Primitives(); - this.entity.addRasterChild(this.#primitives); + this.$$primitives = new Primitives(); + this.entity.addRasterChild(this.$$primitives); } const colorization = this.entity.is('Colorized') ? {rgba: [this.entity.red, this.entity.green, this.entity.blue, 1]} @@ -57,7 +57,7 @@ export default (flecks) => { rgba: [0, 0, 0, 0], ...colorization, }; - this.#primitives.drawCircle( + this.$$primitives.drawCircle( primitive.position || [0, 0], primitive.radius, Primitives.lineStyle(new Color(...line.rgba), line.thickness), @@ -71,27 +71,27 @@ export default (flecks) => { return { blueChanged: () => { - this.#scheduledDraw = true; + this.$$scheduledDraw = true; }, greenChanged: () => { - this.#scheduledDraw = true; + this.$$scheduledDraw = true; }, redChanged: () => { - this.#scheduledDraw = true; + this.$$scheduledDraw = true; }, traitAdded: () => { - this.#scheduledDraw = true; + this.$$scheduledDraw = true; }, }; } renderTick() { - if (this.#scheduledDraw) { - this.#scheduledDraw = false; + if (this.$$scheduledDraw) { + this.$$scheduledDraw = false; this.drawPrimitives(); } } diff --git a/packages/graphics/src/traits/raster-text.js b/packages/graphics/src/traits/raster-text.js index 7123d85..6badeab 100644 --- a/packages/graphics/src/traits/raster-text.js +++ b/packages/graphics/src/traits/raster-text.js @@ -5,7 +5,7 @@ export default (flecks) => { return class RasterText extends Trait { - #text; + $$text; static defaultParams() { return { @@ -22,18 +22,18 @@ export default (flecks) => { destroy() { super.destroy(); - this.entity.removeRasterChild(this.#text); + this.entity.removeRasterChild(this.$$text); } loadText() { if (!this.entity.container) { return; } - if (!this.#text) { - this.#text = new Text(this.entity.text, this.params.textStyle); - this.#text.zIndex = 1000; + if (!this.$$text) { + this.$$text = new Text(this.entity.text, this.params.textStyle); + this.$$text.zIndex = 1000; } - this.entity.addRasterChild(this.#text); + this.entity.addRasterChild(this.$$text); } listeners() { diff --git a/packages/graphics/src/traits/rastered.js b/packages/graphics/src/traits/rastered.js index e770b20..e6a7e8c 100644 --- a/packages/graphics/src/traits/rastered.js +++ b/packages/graphics/src/traits/rastered.js @@ -8,24 +8,24 @@ export default (flecks) => { return class Rastered extends Trait { - #container; + $$container; - #parent; + $$parent; - #siblings = new Set(); + $$siblings = new Set(); - #usingAutoZIndex; + $$usingAutoZIndex; constructor() { super(); if ('web' === process.env.FLECKS_CORE_BUILD_TARGET) { - this.#container = new Container(); - this.#container.on('parentChanged', this.onParentChanged, this); + this.$$container = new Container(); + this.$$container.on('parentChanged', this.onParentChanged, this); } } get container() { - return this.#container; + return this.$$container; } static defaultParams() { @@ -42,9 +42,9 @@ export default (flecks) => { destroy() { super.destroy(); - if (this.#container) { - this.#container.off('parentChanged', this.onParentChanged); - this.#container.destroy(); + if (this.$$container) { + this.$$container.off('parentChanged', this.onParentChanged); + this.$$container.destroy(); } } @@ -52,10 +52,10 @@ export default (flecks) => { return { isVisibleChanged: () => { - if (!this.#container) { + if (!this.$$container) { return; } - this.#container.visible = this.entity.isVisible; + this.$$container.visible = this.entity.isVisible; }, onYChanged: () => { @@ -63,22 +63,22 @@ export default (flecks) => { }, opacityChanged: () => { - if (!this.#container) { + if (!this.$$container) { return; } - this.#container.alpha = this.entity.opacity; + this.$$container.alpha = this.entity.opacity; }, rotationChanged: () => { - if (!this.#container) { + if (!this.$$container) { return; } - this.#container.rotation = this.entity.rotation; + this.$$container.rotation = this.entity.rotation; }, visibleScaleChanged: () => { - if (this.#container) { - this.#container.scale = this.entity.visibleScale; + if (this.$$container) { + this.$$container.scale = this.entity.visibleScale; } }, @@ -92,18 +92,18 @@ export default (flecks) => { async load(json) { await super.load(json); if ('web' === process.env.FLECKS_CORE_BUILD_TARGET) { - if (this.#container) { - this.#container.alpha = this.entity.opacity; - this.#container.rotation = this.entity.rotation; - this.#container.scale = this.entity.visibleScale; + if (this.$$container) { + this.$$container.alpha = this.entity.opacity; + this.$$container.rotation = this.entity.rotation; + this.$$container.scale = this.entity.visibleScale; } this.onZIndexChanged(this.entity.zIndex); this.renderTick(); const {filter} = this.params; if (filter) { - this.#container.setFilter(filter); + this.$$container.setFilter(filter); } - this.#container.isVisible = this.state.isVisible; + this.$$container.isVisible = this.state.isVisible; } } @@ -115,10 +115,10 @@ export default (flecks) => { }, addRasterSibling: (child) => { - if (this.#parent) { - this.#parent.addChild(child); + if (this.$$parent) { + this.$$parent.addChild(child); } - this.#siblings.add(child); + this.$$siblings.add(child); }, removeRasterChild: (child) => { @@ -126,39 +126,39 @@ export default (flecks) => { }, removeRasterSibling: (child) => { - if (this.#parent) { - this.#parent.removeChild(child); + if (this.$$parent) { + this.$$parent.removeChild(child); } - this.#siblings.remove(child); + this.$$siblings.remove(child); }, }; } onParentChanged(oldParent, newParent) { - const siblings = Array.from(this.#siblings); + const siblings = Array.from(this.$$siblings); for (let i = 0; i < siblings.length; i++) { oldParent?.removeChild(siblings[i]); newParent?.addChild(siblings[i]); } if (newParent) { - this.#parent = newParent; + this.$$parent = newParent; } } onYChanged() { - if (this.#usingAutoZIndex) { - this.#container.zIndex = this.entity.y; + if (this.$$usingAutoZIndex) { + this.$$container.zIndex = this.entity.y; } } onZIndexChanged(zIndex) { - this.#usingAutoZIndex = AUTO_ZINDEX === zIndex; - if (!this.#container) { + this.$$usingAutoZIndex = AUTO_ZINDEX === zIndex; + if (!this.$$container) { return; } - if (!this.#usingAutoZIndex) { - this.#container.zIndex = zIndex; + if (!this.$$usingAutoZIndex) { + this.$$container.zIndex = zIndex; } else { this.onYChanged(); @@ -171,15 +171,15 @@ export default (flecks) => { } synchronizePosition() { - if (!this.#container) { + if (!this.$$container) { return; } - this.#container.position = this.entity.position; + this.$$container.position = this.entity.position; } synchronizeZIndex() { - if (this.#container && this.#usingAutoZIndex) { - this.#container.zIndex = this.entity.y; + if (this.$$container && this.$$usingAutoZIndex) { + this.$$container.zIndex = this.entity.y; } } diff --git a/packages/graphics/src/traits/visible.js b/packages/graphics/src/traits/visible.js index 02c6ca5..11e1d39 100644 --- a/packages/graphics/src/traits/visible.js +++ b/packages/graphics/src/traits/visible.js @@ -27,13 +27,13 @@ export default (flecks) => { return class Visible extends decorate(Trait) { - #quadTreeAabb = []; + $$quadTreeAabb = []; - #rawVisibleAabb = [0, 0, 0, 0]; + $$rawVisibleAabb = [0, 0, 0, 0]; - #scheduledBoundingBoxUpdate = true; + $$scheduledBoundingBoxUpdate = true; - #usingAutoZIndex = true; + $$usingAutoZIndex = true; acceptPacket(packet) { if ('TraitUpdateVisible' === packet.constructor.type) { @@ -54,7 +54,7 @@ export default (flecks) => { } // Expand the AABB so we don't have to update it every single tick. const expandedAabb = Rectangle.expand(aabb, [32, 32]); - this.#quadTreeAabb = expandedAabb; + this.$$quadTreeAabb = expandedAabb; list.quadTree.add(this.entity, expandedAabb); } @@ -83,7 +83,7 @@ export default (flecks) => { // Collect all bounding boxes. const visibleAabbs = this.entity.invokeHookFlat('visibleAabbs'); if (0 === visibleAabbs.length) { - this.#rawVisibleAabb = [0, 0, 0, 0]; + this.$$rawVisibleAabb = [0, 0, 0, 0]; } else { let unifiedBoundingBox = [0, 0, 0, 0]; @@ -94,10 +94,10 @@ export default (flecks) => { visibleAabb, ); } - this.#rawVisibleAabb = unifiedBoundingBox; + this.$$rawVisibleAabb = unifiedBoundingBox; } this.translateVisibleAabb(); - this.#scheduledBoundingBoxUpdate = false; + this.$$scheduledBoundingBoxUpdate = false; } listeners() { @@ -134,7 +134,7 @@ export default (flecks) => { }, scheduleBoundingBoxUpdate: () => { - this.#scheduledBoundingBoxUpdate = true; + this.$$scheduledBoundingBoxUpdate = true; }, }; @@ -164,18 +164,18 @@ export default (flecks) => { return; } list.quadTree.remove(this.entity); - this.#quadTreeAabb = []; + this.$$quadTreeAabb = []; } tick() { - if (this.#scheduledBoundingBoxUpdate) { + if (this.$$scheduledBoundingBoxUpdate) { this.forceBoundingBoxUpdate(); } } translateVisibleAabb() { const visibleAabb = Rectangle.translated( - this.#rawVisibleAabb, + this.$$rawVisibleAabb, this.entity.position, ); /* eslint-disable prefer-destructuring */ @@ -192,8 +192,8 @@ export default (flecks) => { return; } if ( - this.#quadTreeAabb.length > 0 - && Rectangle.isInside(this.#quadTreeAabb, this.entity.visibleAabb) + this.$$quadTreeAabb.length > 0 + && Rectangle.isInside(this.$$quadTreeAabb, this.entity.visibleAabb) ) { return; } diff --git a/packages/input/src/action-registry.js b/packages/input/src/action-registry.js index 35d8180..5075e3c 100644 --- a/packages/input/src/action-registry.js +++ b/packages/input/src/action-registry.js @@ -6,16 +6,16 @@ const decorate = compose( export default class ActionRegistry extends decorate(Class) { - #listen = { + $$listen = { joystick: {}, key: {}, button: {}, wheel: {}, }; - #stream = []; + $$stream = []; - #transformers = {}; + $$transformers = {}; constructor(actions) { super(); @@ -26,23 +26,23 @@ export default class ActionRegistry extends decorate(Class) { for (let j = 0; j < candidates.length; ++j) { const {index, type, ...rest} = candidates[j]; if ('joystick' === type) { - if (this.#listen[type][index]) { - this.#listen[type][index].push({action, ...rest}); + if (this.$$listen[type][index]) { + this.$$listen[type][index].push({action, ...rest}); } else { - this.#listen[type][index] = [{action, ...rest}]; + this.$$listen[type][index] = [{action, ...rest}]; } } else { - this.#listen[type][index] = {action}; + this.$$listen[type][index] = {action}; } } } } drain() { - const stream = this.#stream; - this.#stream = []; + const stream = this.$$stream; + this.$$stream = []; return stream; } @@ -69,21 +69,21 @@ export default class ActionRegistry extends decorate(Class) { } onInput(type, input, value, transforming) { - if (this.#listen[type][input]) { + if (this.$$listen[type][input]) { if ('joystick' === type) { - for (let i = 0; i < this.#listen[type][input].length; i++) { - const {action, axis} = this.#listen[type][input][i]; + for (let i = 0; i < this.$$listen[type][input].length; i++) { + const {action, axis} = this.$$listen[type][input][i]; if ( (axis > 0 && value > 0) || (axis < 0 && value < 0) ) { - this.#stream.push({ + this.$$stream.push({ action, value: this.transform(action, value * axis, 'joystick'), }); } else if (0 === value) { - this.#stream.push({ + this.$$stream.push({ action, value: this.transform(action, value, 'joystick'), }); @@ -91,8 +91,8 @@ export default class ActionRegistry extends decorate(Class) { } } else { - const {action} = this.#listen[type][input]; - this.#stream.push({ + const {action} = this.$$listen[type][input]; + this.$$stream.push({ action, value: this.transform(action, value, transforming), }); @@ -121,7 +121,7 @@ export default class ActionRegistry extends decorate(Class) { } setTransformerFor(action, transformer) { - this.#transformers[action] = transformer; + this.$$transformers[action] = transformer; } stopListening() { @@ -138,7 +138,7 @@ export default class ActionRegistry extends decorate(Class) { } transform(action, value, transforming) { - return this.#transformers[action] ? this.#transformers[action](transforming, value) : value; + return this.$$transformers[action] ? this.$$transformers[action](transforming, value) : value; } } diff --git a/packages/input/src/traits/controllable.js b/packages/input/src/traits/controllable.js index 5489e38..b4ea5dd 100644 --- a/packages/input/src/traits/controllable.js +++ b/packages/input/src/traits/controllable.js @@ -12,12 +12,12 @@ const decorate = compose( // Input handling. export default () => class Controllable extends decorate(Trait) { - #actionRegistry; + $$actionRegistry; - #queued = []; + $$queued = []; get actionRegistry() { - return this.#actionRegistry; + return this.$$actionRegistry; } static defaultParams() { @@ -40,7 +40,7 @@ export default () => class Controllable extends decorate(Trait) { destroy() { super.destroy(); - this.#actionRegistry.stopListening(); + this.$$actionRegistry.stopListening(); } get inputActions() { @@ -49,7 +49,7 @@ export default () => class Controllable extends decorate(Trait) { async load(json) { await super.load(json); - this.#actionRegistry = new ActionRegistry(this.params.actions); + this.$$actionRegistry = new ActionRegistry(this.params.actions); } methods() { @@ -63,20 +63,20 @@ export default () => class Controllable extends decorate(Trait) { .every((result) => false !== result) ) { if ('web' === process.env.FLECKS_CORE_BUILD_TARGET) { - this.#queued.push(actionStream[i]); + this.$$queued.push(actionStream[i]); } } } }, drainInput: () => { - const drained = this.#queued; - this.#queued = []; + const drained = this.$$queued; + this.$$queued = []; return drained; }, listenForInput: (inputNormalizer) => { - this.#actionRegistry.listen(inputNormalizer); + this.$$actionRegistry.listen(inputNormalizer); }, }; @@ -84,7 +84,7 @@ export default () => class Controllable extends decorate(Trait) { tick() { if ('web' === process.env.FLECKS_CORE_BUILD_TARGET) { - const drained = this.#actionRegistry.drain(); + const drained = this.$$actionRegistry.drain(); this.entity.acceptActionStream(drained); } } diff --git a/packages/input/src/traits/initiator.js b/packages/input/src/traits/initiator.js index 485b2b1..b1e1013 100644 --- a/packages/input/src/traits/initiator.js +++ b/packages/input/src/traits/initiator.js @@ -5,21 +5,21 @@ import {Trait} from '@avocado/traits'; export default () => class Initiator extends Trait { - #adjustmentThrobber; + $$adjustmentThrobber; - #glowThrobber; + $$glowThrobber; - #ticker = new Ticker(1 / 20); + $$ticker = new Ticker(1 / 20); - #target; + $$target; constructor() { super(); - this.#ticker.on('tick', this.determineTarget, this); + this.$$ticker.on('tick', this.determineTarget, this); if ('web' === process.env.FLECKS_CORE_BUILD_TARGET) { - this.#adjustmentThrobber = {brightness: 1.5}; - this.#adjustmentThrobber.lfo = new LfoResult( - this.#adjustmentThrobber, + this.$$adjustmentThrobber = {brightness: 1.5}; + this.$$adjustmentThrobber.lfo = new LfoResult( + this.$$adjustmentThrobber, { brightness: { frequency: 0.75, @@ -29,9 +29,9 @@ export default () => class Initiator extends Trait { }, }, ); - this.#glowThrobber = {outerStrength: 0.125}; - this.#glowThrobber.lfo = new LfoResult( - this.#glowThrobber, + this.$$glowThrobber = {outerStrength: 0.125}; + this.$$glowThrobber.lfo = new LfoResult( + this.$$glowThrobber, { outerStrength: { frequency: 0.75, @@ -72,9 +72,9 @@ export default () => class Initiator extends Trait { interactives.push(entities[i]); } } - const oldTarget = this.#target; + const oldTarget = this.$$target; if (interactives.length > 0) { - [this.#target] = interactives + [this.$$target] = interactives .filter((interactive) => Rectangle.isTouching(query, interactive.position)) .filter((interactive) => interactive.isInteractive) .map((interactive) => [interactive.distanceFrom({position: incident}), interactive]) @@ -82,10 +82,10 @@ export default () => class Initiator extends Trait { .map(([, interactive]) => interactive); } else { - this.#target = undefined; + this.$$target = undefined; } - if (oldTarget !== this.#target) { - this.targetChanged(oldTarget, this.#target); + if (oldTarget !== this.$$target) { + this.targetChanged(oldTarget, this.$$target); } } @@ -95,8 +95,8 @@ export default () => class Initiator extends Trait { acceptAction: ({action, value}) => { if ('web' !== process.env.FLECKS_CORE_BUILD_TARGET) { if ('Interact' === action && value) { - if (this.#target) { - this.#target.interact(this.entity); + if (this.$$target) { + this.$$target.interact(this.entity); } } } @@ -110,10 +110,10 @@ export default () => class Initiator extends Trait { oldTarget?.container?.removeFilter('interactive', 'adjustment'); oldTarget?.container?.removeFilter('interactive', 'glow'); if ('web' === process.env.FLECKS_CORE_BUILD_TARGET) { - this.#adjustmentThrobber.lfo.properties.brightness.location = 0; - this.#adjustmentThrobber.lfo.tick(0); - this.#glowThrobber.lfo.properties.outerStrength.location = 0; - this.#glowThrobber.lfo.tick(0); + this.$$adjustmentThrobber.lfo.properties.brightness.location = 0; + this.$$adjustmentThrobber.lfo.tick(0); + this.$$glowThrobber.lfo.properties.outerStrength.location = 0; + this.$$glowThrobber.lfo.tick(0); } } @@ -123,19 +123,19 @@ export default () => class Initiator extends Trait { } tick(elapsed) { - this.#ticker.tick(elapsed); + this.$$ticker.tick(elapsed); } tickAdjustment(elapsed) { - const {brightness, lfo} = this.#adjustmentThrobber; + const {brightness, lfo} = this.$$adjustmentThrobber; lfo.tick(elapsed); - this.#target?.container?.addFilter('interactive', 'adjustment', {brightness}); + this.$$target?.container?.addFilter('interactive', 'adjustment', {brightness}); } tickGlow(elapsed) { - const {outerStrength, lfo} = this.#glowThrobber; + const {outerStrength, lfo} = this.$$glowThrobber; lfo.tick(elapsed); - this.#target?.container?.addFilter('interactive', 'glow', {color: 0, outerStrength}); + this.$$target?.container?.addFilter('interactive', 'glow', {color: 0, outerStrength}); } }; diff --git a/packages/input/src/traits/interactive.js b/packages/input/src/traits/interactive.js index e0984e2..d49220a 100644 --- a/packages/input/src/traits/interactive.js +++ b/packages/input/src/traits/interactive.js @@ -7,7 +7,7 @@ const decorate = compose( export default (flecks) => class Interactive extends decorate(Trait) { - #actions; + $$actions; acceptPacket(packet) { if ('TraitInteractive' === packet.constructor.type) { diff --git a/packages/math/src/noise.js b/packages/math/src/noise.js index 4031951..120fc56 100644 --- a/packages/math/src/noise.js +++ b/packages/math/src/noise.js @@ -147,28 +147,28 @@ class FastNoise { }); //private - #Seed = 1337; - #Frequency = 0.01; - #NoiseType = FastNoise.NoiseType.OpenSimplex2; - #RotationType3D = FastNoise.RotationType3D.None; - #TransformType3D = FastNoise.TransformType3D.DefaultOpenSimplex2; - #DomainWarpAmp = 1.0; + $$Seed = 1337; + $$Frequency = 0.01; + $$NoiseType = FastNoise.NoiseType.OpenSimplex2; + $$RotationType3D = FastNoise.RotationType3D.None; + $$TransformType3D = FastNoise.TransformType3D.DefaultOpenSimplex2; + $$DomainWarpAmp = 1.0; - #FractalType = FastNoise.FractalType.None; - #Octaves = 3; - #Lacunarity = 2.0; - #Gain = 0.5; - #WeightedStrength = 0.0; - #PingPongStrength = 2.0; + $$FractalType = FastNoise.FractalType.None; + $$Octaves = 3; + $$Lacunarity = 2.0; + $$Gain = 0.5; + $$WeightedStrength = 0.0; + $$PingPongStrength = 2.0; - #FractalBounding = 1 / 1.75; + $$FractalBounding = 1 / 1.75; - #CellularDistanceFunction = FastNoise.CellularDistanceFunction.EuclideanSq; - #CellularReturnType = FastNoise.CellularReturnType.Distance; - #CellularJitterModifier = 1.0; + $$CellularDistanceFunction = FastNoise.CellularDistanceFunction.EuclideanSq; + $$CellularReturnType = FastNoise.CellularReturnType.Distance; + $$CellularJitterModifier = 1.0; - #DomainWarpType = FastNoise.DomainWarpType.OpenSimplex2; - #WarpTransformType3D = FastNoise.TransformType3D.DefaultOpenSimplex2; + $$DomainWarpType = FastNoise.DomainWarpType.OpenSimplex2; + $$WarpTransformType3D = FastNoise.TransformType3D.DefaultOpenSimplex2; /** * @description Create new FastNoise object with optional seed @@ -177,7 +177,7 @@ class FastNoise { */ constructor(seed) { if (seed !== undefined) { - this.#Seed = seed; + this.$$Seed = seed; } } @@ -188,7 +188,7 @@ class FastNoise { * @param {number} seed */ SetSeed(seed) { - this.#Seed = seed; + this.$$Seed = seed; } /** @@ -198,7 +198,7 @@ class FastNoise { * @param {number} frequency */ SetFrequency(frequency) { - this.#Frequency = frequency; + this.$$Frequency = frequency; } /** @@ -208,8 +208,8 @@ class FastNoise { * @param {FastNoise.NoiseType} noiseType */ SetNoiseType(noiseType) { - this.#NoiseType = noiseType; - this.#UpdateTransformType3D(); + this.$$NoiseType = noiseType; + this.$$UpdateTransformType3D(); } /** @@ -220,9 +220,9 @@ class FastNoise { * @param {FastNoise.RotationType3D} rotationType3D */ SetRotationType3D(rotationType3D) { - this.#RotationType3D = rotationType3D; - this.#UpdateTransformType3D(); - this.#UpdateWarpTransformType3D(); + this.$$RotationType3D = rotationType3D; + this.$$UpdateTransformType3D(); + this.$$UpdateWarpTransformType3D(); } /** @@ -232,7 +232,7 @@ class FastNoise { * @param {FastNoise.FractalType} fractalType */ SetFractalType(fractalType) { - this.#FractalType = fractalType; + this.$$FractalType = fractalType; } /** @@ -242,8 +242,8 @@ class FastNoise { * @param {number} octaves */ SetFractalOctaves(octaves) { - this.#Octaves = octaves; - this.#CalculateFractalBounding(); + this.$$Octaves = octaves; + this.$$CalculateFractalBounding(); } /** @@ -253,7 +253,7 @@ class FastNoise { * @param {number} lacunarity */ SetFractalLacunarity(lacunarity) { - this.#Lacunarity = lacunarity; + this.$$Lacunarity = lacunarity; } /** @@ -263,8 +263,8 @@ class FastNoise { * @param {number} gain */ SetFractalGain(gain) { - this.#Gain = gain; - this.#CalculateFractalBounding(); + this.$$Gain = gain; + this.$$CalculateFractalBounding(); } /** @@ -274,7 +274,7 @@ class FastNoise { * @param {number} weightedStrength */ SetFractalWeightedStrength(weightedStrength) { - this.#WeightedStrength = weightedStrength; + this.$$WeightedStrength = weightedStrength; } /** @@ -284,7 +284,7 @@ class FastNoise { * @param {number} pingPongStrength */ SetFractalPingPongStrength(pingPongStrength) { - this.#PingPongStrength = pingPongStrength; + this.$$PingPongStrength = pingPongStrength; } /** @@ -294,7 +294,7 @@ class FastNoise { * @param {FastNoise.CellularDistanceFunction} cellularDistanceFunction */ SetCellularDistanceFunction(cellularDistanceFunction) { - this.#CellularDistanceFunction = cellularDistanceFunction; + this.$$CellularDistanceFunction = cellularDistanceFunction; } /** @@ -304,7 +304,7 @@ class FastNoise { * @param {FastNoise.CellularReturnType} cellularReturnType */ SetCellularReturnType(cellularReturnType) { - this.#CellularReturnType = cellularReturnType; + this.$$CellularReturnType = cellularReturnType; } /** @@ -314,7 +314,7 @@ class FastNoise { * @param {number} cellularJitter */ SetCellularJitter(cellularJitter) { - this.#CellularJitterModifier = cellularJitter; + this.$$CellularJitterModifier = cellularJitter; } /** @@ -324,8 +324,8 @@ class FastNoise { * @param {FastNoise.DomainWarpType} domainWarpType */ SetDomainWarpType(domainWarpType) { - this.#DomainWarpType = domainWarpType; - this.#UpdateWarpTransformType3D(); + this.$$DomainWarpType = domainWarpType; + this.$$UpdateWarpTransformType3D(); } /** @@ -335,7 +335,7 @@ class FastNoise { * @param {number} domainWarpAmp */ SetDomainWarpAmp(domainWarpAmp) { - this.#DomainWarpAmp = domainWarpAmp; + this.$$DomainWarpAmp = domainWarpAmp; } /** @@ -353,10 +353,10 @@ class FastNoise { * @return {number} Noise output bounded between -1...1 */ let R2 = (x, y) => { - x *= this.#Frequency; - y *= this.#Frequency; + x *= this.$$Frequency; + y *= this.$$Frequency; - switch (this.#NoiseType) { + switch (this.$$NoiseType) { case FastNoise.NoiseType.OpenSimplex2: case FastNoise.NoiseType.OpenSimplex2S: const SQRT3 = 1.7320508075688772935274463415059; @@ -369,15 +369,15 @@ class FastNoise { break; } - switch (this.#FractalType) { + switch (this.$$FractalType) { default: - return this.#GenNoiseSingleR2(this.#Seed, x, y); + return this.$$GenNoiseSingleR2(this.$$Seed, x, y); case FastNoise.FractalType.FBm: - return this.#GenFractalFBmR2(x, y); + return this.$$GenFractalFBmR2(x, y); case FastNoise.FractalType.Ridged: - return this.#GenFractalRidgedR2(x, y); + return this.$$GenFractalRidgedR2(x, y); case FastNoise.FractalType.PingPong: - return this.#GenFractalPingPongR2(x, y); + return this.$$GenFractalPingPongR2(x, y); } }; @@ -389,11 +389,11 @@ class FastNoise { * @return {number} Noise output bounded between -1...1 */ let R3 = (x, y, z) => { - x *= this.#Frequency; - y *= this.#Frequency; - z *= this.#Frequency; + x *= this.$$Frequency; + y *= this.$$Frequency; + z *= this.$$Frequency; - switch (this.#TransformType3D) { + switch (this.$$TransformType3D) { case FastNoise.TransformType3D.ImproveXYPlanes: { let xy = x + y; let s2 = xy * -0.211324865405187; @@ -423,15 +423,15 @@ class FastNoise { break; } - switch (this.#FractalType) { + switch (this.$$FractalType) { default: - return this.#GenNoiseSingleR3(this.#Seed, x, y, z); + return this.$$GenNoiseSingleR3(this.$$Seed, x, y, z); case FastNoise.FractalType.FBm: - return this.#GenFractalFBmR3(x, y, z); + return this.$$GenFractalFBmR3(x, y, z); case FastNoise.FractalType.Ridged: - return this.#GenFractalRidgedR3(x, y, z); + return this.$$GenFractalRidgedR3(x, y, z); case FastNoise.FractalType.PingPong: - return this.#GenFractalPingPongR3(x, y, z); + return this.$$GenFractalPingPongR3(x, y, z); } }; @@ -449,21 +449,21 @@ class FastNoise { * @param {Vector2|Vector3} coord */ DomainWrap(coord) { - switch (this.#FractalType) { + switch (this.$$FractalType) { default: - this.#DomainWarpSingle(coord); + this.$$DomainWarpSingle(coord); break; case FastNoise.FractalType.DomainWarpProgressive: - this.#DomainWarpFractalProgressive(coord); + this.$$DomainWarpFractalProgressive(coord); break; case FastNoise.FractalType.DomainWarpIndependent: - this.#DomainWarpFractalIndependent(coord); + this.$$DomainWarpFractalIndependent(coord); break; } } // prettier-ignore - #Gradients2D = [ + $$Gradients2D = [ 0.130526192220052, 0.99144486137381, 0.38268343236509, 0.923879532511287, 0.608761429008721, 0.793353340291235, 0.793353340291235, 0.608761429008721, 0.923879532511287, 0.38268343236509, 0.99144486137381, 0.130526192220051, 0.99144486137381, -0.130526192220051, 0.923879532511287, -0.38268343236509, 0.793353340291235, -0.60876142900872, 0.608761429008721, -0.793353340291235, 0.38268343236509, -0.923879532511287, 0.130526192220052, -0.99144486137381, @@ -499,7 +499,7 @@ class FastNoise { ]; // prettier-ignore - #RandVecs2D = [ + $$RandVecs2D = [ -0.2700222198, -0.9628540911, 0.3863092627, -0.9223693152, 0.04444859006, -0.999011673, -0.5992523158, -0.8005602176, -0.7819280288, 0.6233687174, 0.9464672271, 0.3227999196, -0.6514146797, -0.7587218957, 0.9378472289, 0.347048376, -0.8497875957, -0.5271252623, -0.879042592, 0.4767432447, -0.892300288, -0.4514423508, -0.379844434, -0.9250503802, -0.9951650832, 0.0982163789, 0.7724397808, -0.6350880136, 0.7573283322, -0.6530343002, -0.9928004525, -0.119780055, -0.0532665713, 0.9985803285, 0.9754253726, -0.2203300762, -0.7665018163, 0.6422421394, 0.991636706, 0.1290606184, -0.994696838, 0.1028503788, -0.5379205513, -0.84299554, 0.5022815471, -0.8647041387, 0.4559821461, -0.8899889226, @@ -535,7 +535,7 @@ class FastNoise { ]; // prettier-ignore - #Gradients3D = [ + $$Gradients3D = [ 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, -1, 0, -1, 0, -1, 0, 1, 1, 0, 0, -1, 1, 0, 0, 1, -1, 0, 0, -1, -1, 0, 0, @@ -555,7 +555,7 @@ class FastNoise { ]; // prettier-ignore - #RandVecs3D = [ + $$RandVecs3D = [ -0.7292736885, -0.6618439697, 0.1735581948, 0, 0.790292081, -0.5480887466, -0.2739291014, 0, 0.7217578935, 0.6226212466, -0.3023380997, 0, 0.565683137, -0.8208298145, -0.0790000257, 0, 0.760049034, -0.5555979497, -0.3370999617, 0, 0.3713945616, 0.5011264475, 0.7816254623, 0, -0.1277062463, -0.4254438999, -0.8959289049, 0, -0.2881560924, -0.5815838982, 0.7607405838, 0, 0.5849561111, -0.662820239, -0.4674352136, 0, 0.3307171178, 0.0391653737, 0.94291689, 0, 0.8712121778, -0.4113374369, -0.2679381538, 0, 0.580981015, 0.7021915846, 0.4115677815, 0, 0.503756873, 0.6330056931, -0.5878203852, 0, 0.4493712205, 0.601390195, 0.6606022552, 0, -0.6878403724, 0.09018890807, -0.7202371714, 0, -0.5958956522, -0.6469350577, 0.475797649, 0, -0.5127052122, 0.1946921978, -0.8361987284, 0, -0.9911507142, -0.05410276466, -0.1212153153, 0, -0.2149721042, 0.9720882117, -0.09397607749, 0, -0.7518650936, -0.5428057603, 0.3742469607, 0, 0.5237068895, 0.8516377189, -0.02107817834, 0, 0.6333504779, 0.1926167129, -0.7495104896, 0, -0.06788241606, 0.3998305789, 0.9140719259, 0, -0.5538628599, -0.4729896695, -0.6852128902, 0, @@ -590,9 +590,9 @@ class FastNoise { -0.7870349638, 0.03447489231, 0.6159443543, 0, -0.2015596421, 0.6859872284, 0.6991389226, 0, -0.08581082512, -0.10920836, -0.9903080513, 0, 0.5532693395, 0.7325250401, -0.396610771, 0, -0.1842489331, -0.9777375055, -0.1004076743, 0, 0.0775473789, -0.9111505856, 0.4047110257, 0, 0.1399838409, 0.7601631212, -0.6344734459, 0, 0.4484419361, -0.845289248, 0.2904925424, 0 ]; - #PrimeX = 501125321; - #PrimeY = 1136930381; - #PrimeZ = 1720413743; + $$PrimeX = 501125321; + $$PrimeY = 1136930381; + $$PrimeZ = 1720413743; /** * @private @@ -601,7 +601,7 @@ class FastNoise { * @param {number} t * @returns {number} */ - static #Lerp(a, b, t) { + static $$Lerp(a, b, t) { return a + t * (b - a); } @@ -610,7 +610,7 @@ class FastNoise { * @param {number} t * @returns {number} */ - static #InterpHermite(t) { + static $$InterpHermite(t) { return t * t * (3 - 2 * t); } @@ -619,7 +619,7 @@ class FastNoise { * @param t * @returns {number} */ - static #InterpQuintic(t) { + static $$InterpQuintic(t) { return t * t * t * (t * (t * 6 - 15) + 10); } @@ -632,7 +632,7 @@ class FastNoise { * @param {number} t * @returns {number} */ - static #CubicLerp(a, b, c, d, t) { + static $$CubicLerp(a, b, c, d, t) { let p = d - c - (a - b); return t * t * t * p + t * t * (a - b - p) + t * (c - a) + b; } @@ -642,7 +642,7 @@ class FastNoise { * @param {number} t * @returns {number} */ - static #PingPong(t) { + static $$PingPong(t) { t -= Math.trunc(t * 0.5 * 2); return t < 1 ? t : 2 - t; } @@ -650,15 +650,15 @@ class FastNoise { /** * @private */ - #CalculateFractalBounding() { - let gain = Math.abs(this.#Gain); + $$CalculateFractalBounding() { + let gain = Math.abs(this.$$Gain); let amp = gain; let ampFractal = 1.0; - for (let i = 1; i < this.#Octaves; i++) { + for (let i = 1; i < this.$$Octaves; i++) { ampFractal += amp; amp *= gain; } - this.#FractalBounding = 1 / ampFractal; + this.$$FractalBounding = 1 / ampFractal; } /** @@ -668,7 +668,7 @@ class FastNoise { * @param {number} yPrimed * @returns {number} */ - #HashR2(seed, xPrimed, yPrimed) { + $$HashR2(seed, xPrimed, yPrimed) { let hash = Math.trunc(seed ^ xPrimed ^ yPrimed); hash = (hash * 0x27d4eb2d) >>> 0; return hash; @@ -682,7 +682,7 @@ class FastNoise { * @param {number} zPrimed * @returns {number} */ - #HashR3(seed, xPrimed, yPrimed, zPrimed){ + $$HashR3(seed, xPrimed, yPrimed, zPrimed){ let hash = Math.trunc(seed ^ xPrimed ^ yPrimed ^ zPrimed); hash = (hash * 0x27d4eb2d) >>> 0; return hash; @@ -695,8 +695,8 @@ class FastNoise { * @param {number} yPrimed * @returns {number} */ - #ValCoordR2(seed, xPrimed, yPrimed) { - let hash = this.#HashR2(seed, xPrimed, yPrimed); + $$ValCoordR2(seed, xPrimed, yPrimed) { + let hash = this.$$HashR2(seed, xPrimed, yPrimed); hash *= hash; hash ^= hash << 19; @@ -711,8 +711,8 @@ class FastNoise { * @param {number} zPrimed * @returns {number} */ - #ValCoordR3(seed, xPrimed, yPrimed, zPrimed){ - let hash = this.#HashR3(seed, xPrimed, yPrimed, zPrimed); + $$ValCoordR3(seed, xPrimed, yPrimed, zPrimed){ + let hash = this.$$HashR3(seed, xPrimed, yPrimed, zPrimed); hash *= hash; hash ^= hash << 19; @@ -728,13 +728,13 @@ class FastNoise { * @param {number} yd * @returns {number} */ - #GradCoordR2(seed, xPrimed, yPrimed, xd, yd) { - let hash = this.#HashR2(seed, xPrimed, yPrimed); + $$GradCoordR2(seed, xPrimed, yPrimed, xd, yd) { + let hash = this.$$HashR2(seed, xPrimed, yPrimed); hash ^= hash >> 15; hash &= 127 << 1; - let xg = this.#Gradients2D[hash]; - let yg = this.#Gradients2D[hash | 1]; + let xg = this.$$Gradients2D[hash]; + let yg = this.$$Gradients2D[hash | 1]; return xd * xg + yd * yg; } @@ -750,14 +750,14 @@ class FastNoise { * @param {number} zd * @returns {number} */ - #GradCoordR3(seed, xPrimed, yPrimed, zPrimed, xd, yd, zd) { - let hash = this.#HashR3(seed, xPrimed, yPrimed, zPrimed); + $$GradCoordR3(seed, xPrimed, yPrimed, zPrimed, xd, yd, zd) { + let hash = this.$$HashR3(seed, xPrimed, yPrimed, zPrimed); hash ^= hash >> 15; hash &= 63 << 2; - let xg = this.#Gradients3D[hash]; - let yg = this.#Gradients3D[hash | 1]; - let zg = this.#Gradients3D[hash | 2]; + let xg = this.$$Gradients3D[hash]; + let yg = this.$$Gradients3D[hash | 1]; + let zg = this.$$Gradients3D[hash | 2]; return xd * xg + yd * yg + zd * zg; } @@ -769,20 +769,20 @@ class FastNoise { * @param {number} y * @returns {number} */ - #GenNoiseSingleR2(seed, x, y) { - switch (this.#NoiseType) { + $$GenNoiseSingleR2(seed, x, y) { + switch (this.$$NoiseType) { case FastNoise.NoiseType.OpenSimplex2: - return this.#SingleOpenSimplex2R2(seed, x, y); + return this.$$SingleOpenSimplex2R2(seed, x, y); case FastNoise.NoiseType.OpenSimplex2S: - return this.#SingleOpenSimplex2SR2(seed, x, y); + return this.$$SingleOpenSimplex2SR2(seed, x, y); case FastNoise.NoiseType.Cellular: - return this.#SingleCellularR2(seed, x, y); + return this.$$SingleCellularR2(seed, x, y); case FastNoise.NoiseType.Perlin: - return this.#SinglePerlinR2(seed, x, y); + return this.$$SinglePerlinR2(seed, x, y); case FastNoise.NoiseType.ValueCubic: - return this.#SingleValueCubicR2(seed, x, y); + return this.$$SingleValueCubicR2(seed, x, y); case FastNoise.NoiseType.Value: - return this.#SingleValueR2(seed, x, y); + return this.$$SingleValueR2(seed, x, y); default: return 0; } @@ -796,20 +796,20 @@ class FastNoise { * @param {number} z * @returns {number} */ - #GenNoiseSingleR3(seed, x, y, z){ - switch (this.#NoiseType) { + $$GenNoiseSingleR3(seed, x, y, z){ + switch (this.$$NoiseType) { case FastNoise.NoiseType.OpenSimplex2: - return this.#SingleOpenSimplex2R3(seed, x, y, z); + return this.$$SingleOpenSimplex2R3(seed, x, y, z); case FastNoise.NoiseType.OpenSimplex2S: - return this.#SingleOpenSimplex2SR3(seed, x, y, z); + return this.$$SingleOpenSimplex2SR3(seed, x, y, z); case FastNoise.NoiseType.Cellular: - return this.#SingleCellularR3(seed, x, y, z); + return this.$$SingleCellularR3(seed, x, y, z); case FastNoise.NoiseType.Perlin: - return this.#SinglePerlinR3(seed, x, y, z); + return this.$$SinglePerlinR3(seed, x, y, z); case FastNoise.NoiseType.ValueCubic: - return this.#SingleValueCubicR3(seed, x, y, z); + return this.$$SingleValueCubicR3(seed, x, y, z); case FastNoise.NoiseType.Value: - return this.#SingleValueR3(seed, x, y, z); + return this.$$SingleValueR3(seed, x, y, z); default: return 0; } @@ -818,22 +818,22 @@ class FastNoise { /** * @private */ - #UpdateTransformType3D() { - switch (this.#RotationType3D) { + $$UpdateTransformType3D() { + switch (this.$$RotationType3D) { case FastNoise.RotationType3D.ImproveXYPlanes: - this.#TransformType3D = FastNoise.TransformType3D.ImproveXYPlanes; + this.$$TransformType3D = FastNoise.TransformType3D.ImproveXYPlanes; break; case FastNoise.RotationType3D.ImproveXZPlanes: - this.#TransformType3D = FastNoise.TransformType3D.ImproveXZPlanes; + this.$$TransformType3D = FastNoise.TransformType3D.ImproveXZPlanes; break; default: - switch (this.#NoiseType) { + switch (this.$$NoiseType) { case FastNoise.NoiseType.OpenSimplex2: case FastNoise.NoiseType.OpenSimplex2S: - this.#TransformType3D = FastNoise.TransformType3D.DefaultOpenSimplex2; + this.$$TransformType3D = FastNoise.TransformType3D.DefaultOpenSimplex2; break; default: - this.#TransformType3D = FastNoise.TransformType3D.None; + this.$$TransformType3D = FastNoise.TransformType3D.None; break; } break; @@ -843,22 +843,22 @@ class FastNoise { /** * @private */ - #UpdateWarpTransformType3D() { - switch (this.#RotationType3D) { + $$UpdateWarpTransformType3D() { + switch (this.$$RotationType3D) { case FastNoise.RotationType3D.ImproveXYPlanes: - this.#WarpTransformType3D = FastNoise.TransformType3D.ImproveXYPlanes; + this.$$WarpTransformType3D = FastNoise.TransformType3D.ImproveXYPlanes; break; case FastNoise.RotationType3D.ImproveXZPlanes: - this.#WarpTransformType3D = FastNoise.TransformType3D.ImproveXZPlanes; + this.$$WarpTransformType3D = FastNoise.TransformType3D.ImproveXZPlanes; break; default: - switch (this.#DomainWarpType) { + switch (this.$$DomainWarpType) { case FastNoise.DomainWarpType.OpenSimplex2: case FastNoise.DomainWarpType.OpenSimplex2Reduced: - this.#WarpTransformType3D = FastNoise.TransformType3D.DefaultOpenSimplex2; + this.$$WarpTransformType3D = FastNoise.TransformType3D.DefaultOpenSimplex2; break; default: - this.#WarpTransformType3D = FastNoise.TransformType3D.None; + this.$$WarpTransformType3D = FastNoise.TransformType3D.None; break; } break; @@ -871,19 +871,19 @@ class FastNoise { * @param {number} y * @returns {number} */ - #GenFractalFBmR2(x,y) { - let seed = this.#Seed; + $$GenFractalFBmR2(x,y) { + let seed = this.$$Seed; let sum = 0; - let amp = this.#FractalBounding; + let amp = this.$$FractalBounding; - for (let i = 0; i < this.#Octaves; i++) { - let noise = this.#GenNoiseSingleR2(seed++, x, y); + for (let i = 0; i < this.$$Octaves; i++) { + let noise = this.$$GenNoiseSingleR2(seed++, x, y); sum += noise * amp; - amp *= FastNoise.#Lerp(1.0, Math.min(noise + 1, 2) * 0.5, this.#WeightedStrength); + amp *= FastNoise.$$Lerp(1.0, Math.min(noise + 1, 2) * 0.5, this.$$WeightedStrength); - x *= this.#Lacunarity; - y *= this.#Lacunarity; - amp *= this.#Gain; + x *= this.$$Lacunarity; + y *= this.$$Lacunarity; + amp *= this.$$Gain; } return sum; } @@ -895,20 +895,20 @@ class FastNoise { * @param {number} z * @returns {number} */ - #GenFractalFBmR3(x,y,z){ - let seed = this.#Seed; + $$GenFractalFBmR3(x,y,z){ + let seed = this.$$Seed; let sum = 0; - let amp = this.#FractalBounding; + let amp = this.$$FractalBounding; - for (let i = 0; i < this.#Octaves; i++) { - let noise = this.#GenNoiseSingleR3(seed++, x, y, z); + for (let i = 0; i < this.$$Octaves; i++) { + let noise = this.$$GenNoiseSingleR3(seed++, x, y, z); sum += noise * amp; - amp *= FastNoise.#Lerp(1.0, (noise + 1) * 0.5, this.#WeightedStrength); + amp *= FastNoise.$$Lerp(1.0, (noise + 1) * 0.5, this.$$WeightedStrength); - x *= this.#Lacunarity; - y *= this.#Lacunarity; - z *= this.#Lacunarity; - amp *= this.#Gain; + x *= this.$$Lacunarity; + y *= this.$$Lacunarity; + z *= this.$$Lacunarity; + amp *= this.$$Gain; } return sum; } @@ -919,19 +919,19 @@ class FastNoise { * @param {number} y * @returns {number} */ - #GenFractalRidgedR2(x,y) { - let seed = this.#Seed; + $$GenFractalRidgedR2(x,y) { + let seed = this.$$Seed; let sum = 0; - let amp = this.#FractalBounding; + let amp = this.$$FractalBounding; - for (let i = 0; i < this.#Octaves; i++) { - let noise = Math.abs(this.#GenNoiseSingleR2(seed++, x, y)); + for (let i = 0; i < this.$$Octaves; i++) { + let noise = Math.abs(this.$$GenNoiseSingleR2(seed++, x, y)); sum += (noise * -2 + 1) * amp; - amp *= FastNoise.#Lerp(1.0, 1 - noise, this.#WeightedStrength); + amp *= FastNoise.$$Lerp(1.0, 1 - noise, this.$$WeightedStrength); - x *= this.#Lacunarity; - y *= this.#Lacunarity; - amp *= this.#Gain; + x *= this.$$Lacunarity; + y *= this.$$Lacunarity; + amp *= this.$$Gain; } return sum; } @@ -943,20 +943,20 @@ class FastNoise { * @param {number} z * @returns {number} */ - #GenFractalRidgedR3(x,y,z){ - let seed = this.#Seed; + $$GenFractalRidgedR3(x,y,z){ + let seed = this.$$Seed; let sum = 0; - let amp = this.#FractalBounding; + let amp = this.$$FractalBounding; - for (let i = 0; i < this.#Octaves; i++) { - let noise = Math.abs(this.#GenNoiseSingleR3(seed++, x, y, z)); + for (let i = 0; i < this.$$Octaves; i++) { + let noise = Math.abs(this.$$GenNoiseSingleR3(seed++, x, y, z)); sum += (noise * -2 + 1) * amp; - amp *= FastNoise.#Lerp(1.0, 1 - noise, this.#WeightedStrength); + amp *= FastNoise.$$Lerp(1.0, 1 - noise, this.$$WeightedStrength); - x *= this.#Lacunarity; - y *= this.#Lacunarity; - z *= this.#Lacunarity; - amp *= this.#Gain; + x *= this.$$Lacunarity; + y *= this.$$Lacunarity; + z *= this.$$Lacunarity; + amp *= this.$$Gain; } return sum; } @@ -967,21 +967,21 @@ class FastNoise { * @param {number} y * @returns {number} */ - #GenFractalPingPongR2(x,y) { - let seed = this.#Seed; + $$GenFractalPingPongR2(x,y) { + let seed = this.$$Seed; let sum = 0; - let amp = this.#FractalBounding; + let amp = this.$$FractalBounding; - for (let i = 0; i < this.#Octaves; i++) { - let noise = FastNoise.#PingPong( - (this.#GenNoiseSingleR2(seed++, x, y) + 1) * this.#PingPongStrength + for (let i = 0; i < this.$$Octaves; i++) { + let noise = FastNoise.$$PingPong( + (this.$$GenNoiseSingleR2(seed++, x, y) + 1) * this.$$PingPongStrength ); sum += (noise - 0.5) * 2 * amp; - amp *= FastNoise.#Lerp(1.0, noise, this.#WeightedStrength); + amp *= FastNoise.$$Lerp(1.0, noise, this.$$WeightedStrength); - x *= this.#Lacunarity; - y *= this.#Lacunarity; - amp *= this.#Gain; + x *= this.$$Lacunarity; + y *= this.$$Lacunarity; + amp *= this.$$Gain; } return sum; } @@ -993,22 +993,22 @@ class FastNoise { * @param {number} z * @returns {number} */ - #GenFractalPingPongR3(x,y,z){ - let seed = this.#Seed; + $$GenFractalPingPongR3(x,y,z){ + let seed = this.$$Seed; let sum = 0; - let amp = this.#FractalBounding; + let amp = this.$$FractalBounding; - for (let i = 0; i < this.#Octaves; i++) { - let noise = FastNoise.#PingPong( - (this.#GenNoiseSingleR3(seed++, x, y, z) + 1) * this.#PingPongStrength + for (let i = 0; i < this.$$Octaves; i++) { + let noise = FastNoise.$$PingPong( + (this.$$GenNoiseSingleR3(seed++, x, y, z) + 1) * this.$$PingPongStrength ); sum += (noise - 0.5) * 2 * amp; - amp *= FastNoise.#Lerp(1.0, noise, this.#WeightedStrength); + amp *= FastNoise.$$Lerp(1.0, noise, this.$$WeightedStrength); - x *= this.#Lacunarity; - y *= this.#Lacunarity; - z *= this.#Lacunarity; - amp *= this.#Gain; + x *= this.$$Lacunarity; + y *= this.$$Lacunarity; + z *= this.$$Lacunarity; + amp *= this.$$Gain; } return sum; } @@ -1020,7 +1020,7 @@ class FastNoise { * @param {number} y * @returns {number} */ - #SingleOpenSimplex2R2(seed,x,y) { + $$SingleOpenSimplex2R2(seed,x,y) { const SQRT3 = 1.7320508075688772935274463415059; const G2 = (3 - SQRT3) / 6; @@ -1033,8 +1033,8 @@ class FastNoise { let x0 = xi - t; let y0 = yi - t; - i *= this.#PrimeX; - j *= this.#PrimeY; + i *= this.$$PrimeX; + j *= this.$$PrimeY; let n0, n1, n2; @@ -1043,7 +1043,7 @@ class FastNoise { if (a <= 0) { n0 = 0; } else { - n0 = a * a * (a * a) * this.#GradCoordR2(seed, i, j, x0, y0); + n0 = a * a * (a * a) * this.$$GradCoordR2(seed, i, j, x0, y0); } let c = 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a); @@ -1053,7 +1053,7 @@ class FastNoise { } else { let x2 = x0 + (2 * G2 - 1); let y2 = y0 + (2 * G2 - 1); - n2 = c * c * (c * c) * this.#GradCoordR2(seed, i + this.#PrimeX, j + this.#PrimeY, x2, y2); + n2 = c * c * (c * c) * this.$$GradCoordR2(seed, i + this.$$PrimeX, j + this.$$PrimeY, x2, y2); } if (y0 > x0) { @@ -1063,7 +1063,7 @@ class FastNoise { if (b <= 0) { n1 = 0; } else { - n1 = b * b * (b * b) * this.#GradCoordR2(seed, i, j + this.#PrimeY, x1, y1); + n1 = b * b * (b * b) * this.$$GradCoordR2(seed, i, j + this.$$PrimeY, x1, y1); } } else { let x1 = x0 + (G2 - 1); @@ -1072,7 +1072,7 @@ class FastNoise { if (b <= 0) { n1 = 0; } else { - n1 = b * b * (b * b) * this.#GradCoordR2(seed, i + this.#PrimeX, j, x1, y1); + n1 = b * b * (b * b) * this.$$GradCoordR2(seed, i + this.$$PrimeX, j, x1, y1); } } return (n0 + n1 + n2) * 99.83685446303647; @@ -1086,7 +1086,7 @@ class FastNoise { * @param {number} z * @returns {number} */ - #SingleOpenSimplex2R3(seed,x,y,z){ + $$SingleOpenSimplex2R3(seed,x,y,z){ let i = Math.round(x); let j = Math.round(y); let k = Math.round(z); @@ -1101,16 +1101,16 @@ class FastNoise { let ax0 = xNSign * -x0; let ay0 = yNSign * -y0; let az0 = zNSign * -z0; - i *= this.#PrimeX; - j *= this.#PrimeY; - k *= this.#PrimeZ; + i *= this.$$PrimeX; + j *= this.$$PrimeY; + k *= this.$$PrimeZ; let value = 0; let a = 0.6 - x0 * x0 - (y0 * y0 + z0 * z0); for (let l = 0; ; l++) { if (a > 0) { - value += a * a * (a * a) * this.#GradCoordR3(seed, i, j, k, x0, y0, z0); + value += a * a * (a * a) * this.$$GradCoordR3(seed, i, j, k, x0, y0, z0); } if (ax0 >= ay0 && ax0 >= az0) { @@ -1121,9 +1121,9 @@ class FastNoise { b * b * (b * b) * - this.#GradCoordR3( + this.$$GradCoordR3( seed, - i - xNSign * this.#PrimeX, + i - xNSign * this.$$PrimeX, j, k, x0 + xNSign, @@ -1139,10 +1139,10 @@ class FastNoise { b * b * (b * b) * - this.#GradCoordR3( + this.$$GradCoordR3( seed, i, - j - yNSign * this.#PrimeY, + j - yNSign * this.$$PrimeY, k, x0, y0 + yNSign, @@ -1157,11 +1157,11 @@ class FastNoise { b * b * (b * b) * - this.#GradCoordR3( + this.$$GradCoordR3( seed, i, j, - k - zNSign * this.#PrimeZ, + k - zNSign * this.$$PrimeZ, x0, y0, z0 + zNSign @@ -1183,9 +1183,9 @@ class FastNoise { a += 0.75 - ax0 - (ay0 + az0); - i += (xNSign >> 1) & this.#PrimeX; - j += (yNSign >> 1) & this.#PrimeY; - k += (zNSign >> 1) & this.#PrimeZ; + i += (xNSign >> 1) & this.$$PrimeX; + j += (yNSign >> 1) & this.$$PrimeY; + k += (zNSign >> 1) & this.$$PrimeZ; xNSign = -xNSign; yNSign = -yNSign; @@ -1203,7 +1203,7 @@ class FastNoise { * @param {number} y * @returns {number} */ - #SingleOpenSimplex2SR2(seed,x,y) { + $$SingleOpenSimplex2SR2(seed,x,y) { // 2D OpenSimplex2S case is a modified 2D simplex noise. const SQRT3 = 1.7320508075688772935274463415059; @@ -1221,21 +1221,21 @@ class FastNoise { let xi = x - i; let yi = y - j; - i *= this.#PrimeX; - j *= this.#PrimeY; - let i1 = i + this.#PrimeX; - let j1 = j + this.#PrimeY; + i *= this.$$PrimeX; + j *= this.$$PrimeY; + let i1 = i + this.$$PrimeX; + let j1 = j + this.$$PrimeY; let t = (xi + yi) * G2; let x0 = xi - t; let y0 = yi - t; let a0 = 2.0 / 3.0 - x0 * x0 - y0 * y0; - let value = a0 * a0 * (a0 * a0) * this.#GradCoordR2(seed, i, j, x0, y0); + let value = a0 * a0 * (a0 * a0) * this.$$GradCoordR2(seed, i, j, x0, y0); let a1 = 2 * (1 - 2 * G2) * (1 / G2 - 2) * t + (-2 * (1 - 2 * G2) * (1 - 2 * G2) + a0); let x1 = x0 - (1 - 2 * G2); let y1 = y0 - (1 - 2 * G2); - value += a1 * a1 * (a1 * a1) * this.#GradCoordR2(seed, i1, j1, x1, y1); + value += a1 * a1 * (a1 * a1) * this.$$GradCoordR2(seed, i1, j1, x1, y1); // Nested conditionals were faster than compact bit logic/arithmetic. let xmyi = xi - yi; @@ -1249,7 +1249,7 @@ class FastNoise { a2 * a2 * (a2 * a2) * - this.#GradCoordR2(seed, i + (this.#PrimeX << 1), j + this.#PrimeY, x2, y2); + this.$$GradCoordR2(seed, i + (this.$$PrimeX << 1), j + this.$$PrimeY, x2, y2); } } else { let x2 = x0 + G2; @@ -1257,7 +1257,7 @@ class FastNoise { let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; if (a2 > 0) { value += - a2 * a2 * (a2 * a2) * this.#GradCoordR2(seed, i, j + this.#PrimeY, x2, y2); + a2 * a2 * (a2 * a2) * this.$$GradCoordR2(seed, i, j + this.$$PrimeY, x2, y2); } } @@ -1270,7 +1270,7 @@ class FastNoise { a3 * a3 * (a3 * a3) * - this.#GradCoordR2(seed, i + this.#PrimeX, j + (this.#PrimeY << 1), x3, y3); + this.$$GradCoordR2(seed, i + this.$$PrimeX, j + (this.$$PrimeY << 1), x3, y3); } } else { let x3 = x0 + (G2 - 1); @@ -1278,7 +1278,7 @@ class FastNoise { let a3 = 2.0 / 3.0 - x3 * x3 - y3 * y3; if (a3 > 0) { value += - a3 * a3 * (a3 * a3) * this.#GradCoordR2(seed, i + this.#PrimeX, j, x3, y3); + a3 * a3 * (a3 * a3) * this.$$GradCoordR2(seed, i + this.$$PrimeX, j, x3, y3); } } } else { @@ -1288,7 +1288,7 @@ class FastNoise { let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; if (a2 > 0) { value += - a2 * a2 * (a2 * a2) * this.#GradCoordR2(seed, i - this.#PrimeX, j, x2, y2); + a2 * a2 * (a2 * a2) * this.$$GradCoordR2(seed, i - this.$$PrimeX, j, x2, y2); } } else { let x2 = x0 + (G2 - 1); @@ -1296,7 +1296,7 @@ class FastNoise { let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; if (a2 > 0) { value += - a2 * a2 * (a2 * a2) * this.#GradCoordR2(seed, i + this.#PrimeX, j, x2, y2); + a2 * a2 * (a2 * a2) * this.$$GradCoordR2(seed, i + this.$$PrimeX, j, x2, y2); } } @@ -1306,7 +1306,7 @@ class FastNoise { let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; if (a2 > 0) { value += - a2 * a2 * (a2 * a2) * this.#GradCoordR2(seed, i, j - this.#PrimeY, x2, y2); + a2 * a2 * (a2 * a2) * this.$$GradCoordR2(seed, i, j - this.$$PrimeY, x2, y2); } } else { let x2 = x0 + G2; @@ -1314,7 +1314,7 @@ class FastNoise { let a2 = 2.0 / 3.0 - x2 * x2 - y2 * y2; if (a2 > 0) { value += - a2 * a2 * (a2 * a2) * this.#GradCoordR2(seed, i, j + this.#PrimeY, x2, y2); + a2 * a2 * (a2 * a2) * this.$$GradCoordR2(seed, i, j + this.$$PrimeY, x2, y2); } } } @@ -1330,7 +1330,7 @@ class FastNoise { * @param {number} z * @returns {number} */ - #SingleOpenSimplex2SR3 (seed, x, y, z) { + $$SingleOpenSimplex2SR3 (seed, x, y, z) { // 3D OpenSimplex2S case uses two offset rotated cube grids. /* @@ -1347,9 +1347,9 @@ class FastNoise { let yi = y - j; let zi = z - k; - i *= this.#PrimeX; - j *= this.#PrimeY; - k *= this.#PrimeZ; + i *= this.$$PrimeX; + j *= this.$$PrimeY; + k *= this.$$PrimeZ; let seed2 = seed + 1293373; let xNMask = Math.trunc(-0.5 - xi); @@ -1364,11 +1364,11 @@ class FastNoise { a0 * a0 * (a0 * a0) * - this.#GradCoordR3( + this.$$GradCoordR3( seed, - i + (xNMask & this.#PrimeX), - j + (yNMask & this.#PrimeY), - k + (zNMask & this.#PrimeZ), + i + (xNMask & this.$$PrimeX), + j + (yNMask & this.$$PrimeY), + k + (zNMask & this.$$PrimeZ), x0, y0, z0 @@ -1382,7 +1382,7 @@ class FastNoise { a1 * a1 * (a1 * a1) * - this.#GradCoordR3(seed2, i + this.#PrimeX, j + this.#PrimeY, k + this.#PrimeZ, x1, y1, z1); + this.$$GradCoordR3(seed2, i + this.$$PrimeX, j + this.$$PrimeY, k + this.$$PrimeZ, x1, y1, z1); let xAFlipMask0 = ((xNMask | 1) << 1) * x1; let yAFlipMask0 = ((yNMask | 1) << 1) * y1; @@ -1399,11 +1399,11 @@ class FastNoise { a2 * a2 * (a2 * a2) * - this.#GradCoordR3( + this.$$GradCoordR3( seed, - i + (~xNMask & this.#PrimeX), - j + (yNMask & this.#PrimeY), - k + (zNMask & this.#PrimeZ), + i + (~xNMask & this.$$PrimeX), + j + (yNMask & this.$$PrimeY), + k + (zNMask & this.$$PrimeZ), x2, y0, z0 @@ -1419,11 +1419,11 @@ class FastNoise { a3 * a3 * (a3 * a3) * - this.#GradCoordR3( + this.$$GradCoordR3( seed, - i + (xNMask & this.#PrimeX), - j + (~yNMask & this.#PrimeY), - k + (~zNMask & this.#PrimeZ), + i + (xNMask & this.$$PrimeX), + j + (~yNMask & this.$$PrimeY), + k + (~zNMask & this.$$PrimeZ), x3, y3, z3 @@ -1437,11 +1437,11 @@ class FastNoise { a4 * a4 * (a4 * a4) * - this.#GradCoordR3( + this.$$GradCoordR3( seed2, - i + (xNMask & (this.#PrimeX * 2)), - j + this.#PrimeY, - k + this.#PrimeZ, + i + (xNMask & (this.$$PrimeX * 2)), + j + this.$$PrimeY, + k + this.$$PrimeZ, x4, y1, z1 @@ -1459,11 +1459,11 @@ class FastNoise { a6 * a6 * (a6 * a6) * - this.#GradCoordR3( + this.$$GradCoordR3( seed, - i + (xNMask & this.#PrimeX), - j + (~yNMask & this.#PrimeY), - k + (zNMask & this.#PrimeZ), + i + (xNMask & this.$$PrimeX), + j + (~yNMask & this.$$PrimeY), + k + (zNMask & this.$$PrimeZ), x6, y6, z0 @@ -1478,11 +1478,11 @@ class FastNoise { a7 * a7 * (a7 * a7) * - this.#GradCoordR3( + this.$$GradCoordR3( seed, - i + (~xNMask & this.#PrimeX), - j + (yNMask & this.#PrimeY), - k + (~zNMask & this.#PrimeZ), + i + (~xNMask & this.$$PrimeX), + j + (yNMask & this.$$PrimeY), + k + (~zNMask & this.$$PrimeZ), x7, y7, z7 @@ -1497,11 +1497,11 @@ class FastNoise { a8 * a8 * (a8 * a8) * - this.#GradCoordR3( + this.$$GradCoordR3( seed2, - i + this.#PrimeX, - j + (yNMask & (this.#PrimeY << 1)), - k + this.#PrimeZ, + i + this.$$PrimeX, + j + (yNMask & (this.$$PrimeY << 1)), + k + this.$$PrimeZ, x8, y8, z1 @@ -1520,11 +1520,11 @@ class FastNoise { aA * aA * (aA * aA) * - this.#GradCoordR3( + this.$$GradCoordR3( seed, - i + (xNMask & this.#PrimeX), - j + (yNMask & this.#PrimeY), - k + (~zNMask & this.#PrimeZ), + i + (xNMask & this.$$PrimeX), + j + (yNMask & this.$$PrimeY), + k + (~zNMask & this.$$PrimeZ), xA, yA, zA @@ -1538,11 +1538,11 @@ class FastNoise { aB * aB * (aB * aB) * - this.#GradCoordR3( + this.$$GradCoordR3( seed, - i + (~xNMask & this.#PrimeX), - j + (~yNMask & this.#PrimeY), - k + (zNMask & this.#PrimeZ), + i + (~xNMask & this.$$PrimeX), + j + (~yNMask & this.$$PrimeY), + k + (zNMask & this.$$PrimeZ), xB, yB, z0 @@ -1558,11 +1558,11 @@ class FastNoise { aC * aC * (aC * aC) * - this.#GradCoordR3( + this.$$GradCoordR3( seed2, - i + this.#PrimeX, - j + this.#PrimeY, - k + (zNMask & (this.#PrimeZ << 1)), + i + this.$$PrimeX, + j + this.$$PrimeY, + k + (zNMask & (this.$$PrimeZ << 1)), xC, yC, zC @@ -1581,11 +1581,11 @@ class FastNoise { a5 * a5 * (a5 * a5) * - this.#GradCoordR3( + this.$$GradCoordR3( seed2, - i + this.#PrimeX, - j + (yNMask & (this.#PrimeY << 1)), - k + (zNMask & (this.#PrimeZ << 1)), + i + this.$$PrimeX, + j + (yNMask & (this.$$PrimeY << 1)), + k + (zNMask & (this.$$PrimeZ << 1)), x5, y5, z5 @@ -1603,11 +1603,11 @@ class FastNoise { a9 * a9 * (a9 * a9) * - this.#GradCoordR3( + this.$$GradCoordR3( seed2, - i + (xNMask & (this.#PrimeX * 2)), - j + this.#PrimeY, - k + (zNMask & (this.#PrimeZ << 1)), + i + (xNMask & (this.$$PrimeX * 2)), + j + this.$$PrimeY, + k + (zNMask & (this.$$PrimeZ << 1)), x9, y9, z9 @@ -1624,11 +1624,11 @@ class FastNoise { aD * aD * (aD * aD) * - this.#GradCoordR3( + this.$$GradCoordR3( seed2, - i + (xNMask & (this.#PrimeX << 1)), - j + (yNMask & (this.#PrimeY << 1)), - k + this.#PrimeZ, + i + (xNMask & (this.$$PrimeX << 1)), + j + (yNMask & (this.$$PrimeY << 1)), + k + this.$$PrimeZ, xD, yD, z1 @@ -1646,7 +1646,7 @@ class FastNoise { * @param {number} y * @returns {number} */ - #SingleCellularR2(seed,x,y) { + $$SingleCellularR2(seed,x,y) { /** * * @param {number} seed @@ -1662,12 +1662,12 @@ class FastNoise { let closestHash = 0; - let cellularJitter = 0.43701595 * this.#CellularJitterModifier; + let cellularJitter = 0.43701595 * this.$$CellularJitterModifier; - let xPrimed = (xr - 1) * this.#PrimeX; - let yPrimedBase = (yr - 1) * this.#PrimeY; + let xPrimed = (xr - 1) * this.$$PrimeX; + let yPrimedBase = (yr - 1) * this.$$PrimeY; - switch (this.#CellularDistanceFunction) { + switch (this.$$CellularDistanceFunction) { default: case FastNoise.CellularDistanceFunction.Euclidean: case FastNoise.CellularDistanceFunction.EuclideanSq: @@ -1675,11 +1675,11 @@ class FastNoise { let yPrimed = yPrimedBase; for (let yi = yr - 1; yi <= yr + 1; yi++) { - let hash = this.#HashR2(seed, xPrimed, yPrimed); + let hash = this.$$HashR2(seed, xPrimed, yPrimed); let idx = hash & (255 << 1); - let vecX = xi - x + this.#RandVecs2D[idx] * cellularJitter; - let vecY = yi - y + this.#RandVecs2D[idx | 1] * cellularJitter; + let vecX = xi - x + this.$$RandVecs2D[idx] * cellularJitter; + let vecY = yi - y + this.$$RandVecs2D[idx | 1] * cellularJitter; let newDistance = vecX * vecX + vecY * vecY; @@ -1688,9 +1688,9 @@ class FastNoise { distance0 = newDistance; closestHash = hash; } - yPrimed += this.#PrimeY; + yPrimed += this.$$PrimeY; } - xPrimed += this.#PrimeX; + xPrimed += this.$$PrimeX; } break; case FastNoise.CellularDistanceFunction.Manhattan: @@ -1698,11 +1698,11 @@ class FastNoise { let yPrimed = yPrimedBase; for (let yi = yr - 1; yi <= yr + 1; yi++) { - let hash = this.#HashR2(seed, xPrimed, yPrimed); + let hash = this.$$HashR2(seed, xPrimed, yPrimed); let idx = hash & (255 << 1); - let vecX = xi - x + this.#RandVecs2D[idx] * cellularJitter; - let vecY = yi - y + this.#RandVecs2D[idx | 1] * cellularJitter; + let vecX = xi - x + this.$$RandVecs2D[idx] * cellularJitter; + let vecY = yi - y + this.$$RandVecs2D[idx | 1] * cellularJitter; let newDistance = Math.abs(vecX) + Math.abs(vecY); @@ -1711,9 +1711,9 @@ class FastNoise { distance0 = newDistance; closestHash = hash; } - yPrimed += this.#PrimeY; + yPrimed += this.$$PrimeY; } - xPrimed += this.#PrimeX; + xPrimed += this.$$PrimeX; } break; case FastNoise.CellularDistanceFunction.Hybrid: @@ -1721,11 +1721,11 @@ class FastNoise { let yPrimed = yPrimedBase; for (let yi = yr - 1; yi <= yr + 1; yi++) { - let hash = this.#HashR2(seed, xPrimed, yPrimed); + let hash = this.$$HashR2(seed, xPrimed, yPrimed); let idx = hash & (255 << 1); - let vecX = xi - x + this.#RandVecs2D[idx] * cellularJitter; - let vecY = yi - y + this.#RandVecs2D[idx | 1] * cellularJitter; + let vecX = xi - x + this.$$RandVecs2D[idx] * cellularJitter; + let vecY = yi - y + this.$$RandVecs2D[idx | 1] * cellularJitter; let newDistance = Math.abs(vecX) + Math.abs(vecY) + (vecX * vecX + vecY * vecY); @@ -1735,25 +1735,25 @@ class FastNoise { distance0 = newDistance; closestHash = hash; } - yPrimed += this.#PrimeY; + yPrimed += this.$$PrimeY; } - xPrimed += this.#PrimeX; + xPrimed += this.$$PrimeX; } break; } if ( - this.#CellularDistanceFunction === FastNoise.CellularDistanceFunction.Euclidean && - this.#CellularReturnType !== FastNoise.CellularReturnType.CellValue + this.$$CellularDistanceFunction === FastNoise.CellularDistanceFunction.Euclidean && + this.$$CellularReturnType !== FastNoise.CellularReturnType.CellValue ) { distance0 = Math.sqrt(distance0); - if (this.#CellularReturnType !== FastNoise.CellularReturnType.CellValue) { + if (this.$$CellularReturnType !== FastNoise.CellularReturnType.CellValue) { distance1 = Math.sqrt(distance1); } } - switch (this.#CellularReturnType) { + switch (this.$$CellularReturnType) { case FastNoise.CellularReturnType.CellValue: return closestHash * (1 / 2147483648.0); case FastNoise.CellularReturnType.Distance: @@ -1782,7 +1782,7 @@ class FastNoise { * @param {number} z * @returns {number} */ - #SingleCellularR3 (seed, x, y, z) { + $$SingleCellularR3 (seed, x, y, z) { let xr = Math.round(x); let yr = Math.round(y); let zr = Math.round(z); @@ -1791,13 +1791,13 @@ class FastNoise { let distance1 = Number.MAX_VALUE; let closestHash = 0; - let cellularJitter = 0.39614353 * this.#CellularJitterModifier; + let cellularJitter = 0.39614353 * this.$$CellularJitterModifier; - let xPrimed = (xr - 1) * this.#PrimeX; - let yPrimedBase = (yr - 1) * this.#PrimeY; - let zPrimedBase = (zr - 1) * this.#PrimeZ; + let xPrimed = (xr - 1) * this.$$PrimeX; + let yPrimedBase = (yr - 1) * this.$$PrimeY; + let zPrimedBase = (zr - 1) * this.$$PrimeZ; - switch (this.#CellularDistanceFunction) { + switch (this.$$CellularDistanceFunction) { case FastNoise.CellularDistanceFunction.Euclidean: case FastNoise.CellularDistanceFunction.EuclideanSq: for (let xi = xr - 1; xi <= xr + 1; xi++) { @@ -1807,12 +1807,12 @@ class FastNoise { let zPrimed = zPrimedBase; for (let zi = zr - 1; zi <= zr + 1; zi++) { - let hash = this.#HashR3(seed, xPrimed, yPrimed, zPrimed); + let hash = this.$$HashR3(seed, xPrimed, yPrimed, zPrimed); let idx = hash & (255 << 2); - let vecX = xi - x + this.#RandVecs3D[idx] * cellularJitter; - let vecY = yi - y + this.#RandVecs3D[idx | 1] * cellularJitter; - let vecZ = zi - z + this.#RandVecs3D[idx | 2] * cellularJitter; + let vecX = xi - x + this.$$RandVecs3D[idx] * cellularJitter; + let vecY = yi - y + this.$$RandVecs3D[idx | 1] * cellularJitter; + let vecZ = zi - z + this.$$RandVecs3D[idx | 2] * cellularJitter; let newDistance = vecX * vecX + vecY * vecY + vecZ * vecZ; @@ -1821,11 +1821,11 @@ class FastNoise { distance0 = newDistance; closestHash = hash; } - zPrimed += this.#PrimeZ; + zPrimed += this.$$PrimeZ; } - yPrimed += this.#PrimeY; + yPrimed += this.$$PrimeY; } - xPrimed += this.#PrimeX; + xPrimed += this.$$PrimeX; } break; case FastNoise.CellularDistanceFunction.Manhattan: @@ -1836,12 +1836,12 @@ class FastNoise { let zPrimed = zPrimedBase; for (let zi = zr - 1; zi <= zr + 1; zi++) { - let hash = this.#HashR3(seed, xPrimed, yPrimed, zPrimed); + let hash = this.$$HashR3(seed, xPrimed, yPrimed, zPrimed); let idx = hash & (255 << 2); - let vecX = xi - x + this.#RandVecs3D[idx] * cellularJitter; - let vecY = yi - y + this.#RandVecs3D[idx | 1] * cellularJitter; - let vecZ = zi - z + this.#RandVecs3D[idx | 2] * cellularJitter; + let vecX = xi - x + this.$$RandVecs3D[idx] * cellularJitter; + let vecY = yi - y + this.$$RandVecs3D[idx | 1] * cellularJitter; + let vecZ = zi - z + this.$$RandVecs3D[idx | 2] * cellularJitter; let newDistance = Math.abs(vecX) + Math.abs(vecY) + Math.abs(vecZ); @@ -1850,11 +1850,11 @@ class FastNoise { distance0 = newDistance; closestHash = hash; } - zPrimed += this.#PrimeZ; + zPrimed += this.$$PrimeZ; } - yPrimed += this.#PrimeY; + yPrimed += this.$$PrimeY; } - xPrimed += this.#PrimeX; + xPrimed += this.$$PrimeX; } break; case FastNoise.CellularDistanceFunction.Hybrid: @@ -1865,12 +1865,12 @@ class FastNoise { let zPrimed = zPrimedBase; for (let zi = zr - 1; zi <= zr + 1; zi++) { - let hash = this.#HashR3(seed, xPrimed, yPrimed, zPrimed); + let hash = this.$$HashR3(seed, xPrimed, yPrimed, zPrimed); let idx = hash & (255 << 2); - let vecX = xi - x + this.#RandVecs3D[idx] * cellularJitter; - let vecY = yi - y + this.#RandVecs3D[idx | 1] * cellularJitter; - let vecZ = zi - z + this.#RandVecs3D[idx | 2] * cellularJitter; + let vecX = xi - x + this.$$RandVecs3D[idx] * cellularJitter; + let vecY = yi - y + this.$$RandVecs3D[idx | 1] * cellularJitter; + let vecZ = zi - z + this.$$RandVecs3D[idx | 2] * cellularJitter; let newDistance = Math.abs(vecX) + @@ -1883,11 +1883,11 @@ class FastNoise { distance0 = newDistance; closestHash = hash; } - zPrimed += this.#PrimeZ; + zPrimed += this.$$PrimeZ; } - yPrimed += this.#PrimeY; + yPrimed += this.$$PrimeY; } - xPrimed += this.#PrimeX; + xPrimed += this.$$PrimeX; } break; default: @@ -1895,17 +1895,17 @@ class FastNoise { } if ( - this.#CellularDistanceFunction === FastNoise.CellularDistanceFunction.Euclidean && - this.#CellularReturnType !== FastNoise.CellularReturnType.CellValue + this.$$CellularDistanceFunction === FastNoise.CellularDistanceFunction.Euclidean && + this.$$CellularReturnType !== FastNoise.CellularReturnType.CellValue ) { distance0 = Math.sqrt(distance0); - if (this.#CellularReturnType !== FastNoise.CellularReturnType.CellValue) { + if (this.$$CellularReturnType !== FastNoise.CellularReturnType.CellValue) { distance1 = Math.sqrt(distance1); } } - switch (this.#CellularReturnType) { + switch (this.$$CellularReturnType) { case FastNoise.CellularReturnType.CellValue: return closestHash * (1 / 2147483648.0); case FastNoise.CellularReturnType.Distance: @@ -1932,7 +1932,7 @@ class FastNoise { * @param {number} y * @returns {number} */ - #SinglePerlinR2(seed, x, y) { + $$SinglePerlinR2(seed, x, y) { let x0 = Math.floor(x); let y0 = Math.floor(y); @@ -1941,26 +1941,26 @@ class FastNoise { let xd1 = xd0 - 1; let yd1 = yd0 - 1; - let xs = FastNoise.#InterpQuintic(xd0); - let ys = FastNoise.#InterpQuintic(yd0); + let xs = FastNoise.$$InterpQuintic(xd0); + let ys = FastNoise.$$InterpQuintic(yd0); - x0 *= this.#PrimeX; - y0 *= this.#PrimeY; - let x1 = x0 + this.#PrimeX; - let y1 = y0 + this.#PrimeY; + x0 *= this.$$PrimeX; + y0 *= this.$$PrimeY; + let x1 = x0 + this.$$PrimeX; + let y1 = y0 + this.$$PrimeY; - let xf0 = FastNoise.#Lerp( - this.#GradCoordR2(seed, x0, y0, xd0, yd0), - this.#GradCoordR2(seed, x1, y0, xd1, yd0), + let xf0 = FastNoise.$$Lerp( + this.$$GradCoordR2(seed, x0, y0, xd0, yd0), + this.$$GradCoordR2(seed, x1, y0, xd1, yd0), xs ); - let xf1 = FastNoise.#Lerp( - this.#GradCoordR2(seed, x0, y1, xd0, yd1), - this.#GradCoordR2(seed, x1, y1, xd1, yd1), + let xf1 = FastNoise.$$Lerp( + this.$$GradCoordR2(seed, x0, y1, xd0, yd1), + this.$$GradCoordR2(seed, x1, y1, xd1, yd1), xs ); - return FastNoise.#Lerp(xf0, xf1, ys) * 1.4247691104677813; + return FastNoise.$$Lerp(xf0, xf1, ys) * 1.4247691104677813; } /** @@ -1971,7 +1971,7 @@ class FastNoise { * @param {number} z * @returns {number} */ - #SinglePerlinR3 (seed, x, y, z) { + $$SinglePerlinR3 (seed, x, y, z) { let x0 = Math.floor(x); let y0 = Math.floor(y); let z0 = Math.floor(z); @@ -1983,42 +1983,42 @@ class FastNoise { let yd1 = yd0 - 1; let zd1 = zd0 - 1; - let xs = FastNoise.#InterpQuintic(xd0); - let ys = FastNoise.#InterpQuintic(yd0); - let zs = FastNoise.#InterpQuintic(zd0); + let xs = FastNoise.$$InterpQuintic(xd0); + let ys = FastNoise.$$InterpQuintic(yd0); + let zs = FastNoise.$$InterpQuintic(zd0); - x0 *= this.#PrimeX; - y0 *= this.#PrimeY; - z0 *= this.#PrimeZ; - let x1 = x0 + this.#PrimeX; - let y1 = y0 + this.#PrimeY; - let z1 = z0 + this.#PrimeZ; + x0 *= this.$$PrimeX; + y0 *= this.$$PrimeY; + z0 *= this.$$PrimeZ; + let x1 = x0 + this.$$PrimeX; + let y1 = y0 + this.$$PrimeY; + let z1 = z0 + this.$$PrimeZ; - let xf00 = FastNoise.#Lerp( - this.#GradCoordR3(seed, x0, y0, z0, xd0, yd0, zd0), - this.#GradCoordR3(seed, x1, y0, z0, xd1, yd0, zd0), + let xf00 = FastNoise.$$Lerp( + this.$$GradCoordR3(seed, x0, y0, z0, xd0, yd0, zd0), + this.$$GradCoordR3(seed, x1, y0, z0, xd1, yd0, zd0), xs ); - let xf10 = FastNoise.#Lerp( - this.#GradCoordR3(seed, x0, y1, z0, xd0, yd1, zd0), - this.#GradCoordR3(seed, x1, y1, z0, xd1, yd1, zd0), + let xf10 = FastNoise.$$Lerp( + this.$$GradCoordR3(seed, x0, y1, z0, xd0, yd1, zd0), + this.$$GradCoordR3(seed, x1, y1, z0, xd1, yd1, zd0), xs ); - let xf01 = FastNoise.#Lerp( - this.#GradCoordR3(seed, x0, y0, z1, xd0, yd0, zd1), - this.#GradCoordR3(seed, x1, y0, z1, xd1, yd0, zd1), + let xf01 = FastNoise.$$Lerp( + this.$$GradCoordR3(seed, x0, y0, z1, xd0, yd0, zd1), + this.$$GradCoordR3(seed, x1, y0, z1, xd1, yd0, zd1), xs ); - let xf11 = FastNoise.#Lerp( - this.#GradCoordR3(seed, x0, y1, z1, xd0, yd1, zd1), - this.#GradCoordR3(seed, x1, y1, z1, xd1, yd1, zd1), + let xf11 = FastNoise.$$Lerp( + this.$$GradCoordR3(seed, x0, y1, z1, xd0, yd1, zd1), + this.$$GradCoordR3(seed, x1, y1, z1, xd1, yd1, zd1), xs ); - let yf0 = FastNoise.#Lerp(xf00, xf10, ys); - let yf1 = FastNoise.#Lerp(xf01, xf11, ys); + let yf0 = FastNoise.$$Lerp(xf00, xf10, ys); + let yf1 = FastNoise.$$Lerp(xf01, xf11, ys); - return FastNoise.#Lerp(yf0, yf1, zs) * 0.964921414852142333984375; + return FastNoise.$$Lerp(yf0, yf1, zs) * 0.964921414852142333984375; } /** @@ -2028,50 +2028,50 @@ class FastNoise { * @param {number} y * @returns {number} */ - #SingleValueCubicR2(seed, x, y) { + $$SingleValueCubicR2(seed, x, y) { let x1 = Math.floor(x); let y1 = Math.floor(y); let xs = x - x1; let ys = y - y1; - x1 *= this.#PrimeX; - y1 *= this.#PrimeY; - let x0 = x1 - this.#PrimeX; - let y0 = y1 - this.#PrimeY; - let x2 = x1 + this.#PrimeX; - let y2 = y1 + this.#PrimeY; - let x3 = x1 + (this.#PrimeX << 1); - let y3 = y1 + (this.#PrimeY << 1); + x1 *= this.$$PrimeX; + y1 *= this.$$PrimeY; + let x0 = x1 - this.$$PrimeX; + let y0 = y1 - this.$$PrimeY; + let x2 = x1 + this.$$PrimeX; + let y2 = y1 + this.$$PrimeY; + let x3 = x1 + (this.$$PrimeX << 1); + let y3 = y1 + (this.$$PrimeY << 1); return ( - FastNoise.#CubicLerp( - FastNoise.#CubicLerp( - this.#ValCoordR2(seed, x0, y0), - this.#ValCoordR2(seed, x1, y0), - this.#ValCoordR2(seed, x2, y0), - this.#ValCoordR2(seed, x3, y0), + FastNoise.$$CubicLerp( + FastNoise.$$CubicLerp( + this.$$ValCoordR2(seed, x0, y0), + this.$$ValCoordR2(seed, x1, y0), + this.$$ValCoordR2(seed, x2, y0), + this.$$ValCoordR2(seed, x3, y0), xs ), - FastNoise.#CubicLerp( - this.#ValCoordR2(seed, x0, y1), - this.#ValCoordR2(seed, x1, y1), - this.#ValCoordR2(seed, x2, y1), - this.#ValCoordR2(seed, x3, y1), + FastNoise.$$CubicLerp( + this.$$ValCoordR2(seed, x0, y1), + this.$$ValCoordR2(seed, x1, y1), + this.$$ValCoordR2(seed, x2, y1), + this.$$ValCoordR2(seed, x3, y1), xs ), - FastNoise.#CubicLerp( - this.#ValCoordR2(seed, x0, y2), - this.#ValCoordR2(seed, x1, y2), - this.#ValCoordR2(seed, x2, y2), - this.#ValCoordR2(seed, x3, y2), + FastNoise.$$CubicLerp( + this.$$ValCoordR2(seed, x0, y2), + this.$$ValCoordR2(seed, x1, y2), + this.$$ValCoordR2(seed, x2, y2), + this.$$ValCoordR2(seed, x3, y2), xs ), - FastNoise.#CubicLerp( - this.#ValCoordR2(seed, x0, y3), - this.#ValCoordR2(seed, x1, y3), - this.#ValCoordR2(seed, x2, y3), - this.#ValCoordR2(seed, x3, y3), + FastNoise.$$CubicLerp( + this.$$ValCoordR2(seed, x0, y3), + this.$$ValCoordR2(seed, x1, y3), + this.$$ValCoordR2(seed, x2, y3), + this.$$ValCoordR2(seed, x3, y3), xs ), ys @@ -2088,7 +2088,7 @@ class FastNoise { * @param {number} z * @returns {number} */ - #SingleValueCubicR3(seed, x, y, z) { + $$SingleValueCubicR3(seed, x, y, z) { let x1 = Math.floor(x); let y1 = Math.floor(y); let z1 = Math.floor(z); @@ -2097,142 +2097,142 @@ class FastNoise { let ys = y - y1; let zs = z - z1; - x1 *= this.#PrimeX; - y1 *= this.#PrimeY; - z1 *= this.#PrimeZ; + x1 *= this.$$PrimeX; + y1 *= this.$$PrimeY; + z1 *= this.$$PrimeZ; - let x0 = x1 - this.#PrimeX; - let y0 = y1 - this.#PrimeY; - let z0 = z1 - this.#PrimeZ; - let x2 = x1 + this.#PrimeX; - let y2 = y1 + this.#PrimeY; - let z2 = z1 + this.#PrimeZ; - let x3 = x1 + (this.#PrimeX << 1); - let y3 = y1 + (this.#PrimeY << 1); - let z3 = z1 + (this.#PrimeZ << 1); + let x0 = x1 - this.$$PrimeX; + let y0 = y1 - this.$$PrimeY; + let z0 = z1 - this.$$PrimeZ; + let x2 = x1 + this.$$PrimeX; + let y2 = y1 + this.$$PrimeY; + let z2 = z1 + this.$$PrimeZ; + let x3 = x1 + (this.$$PrimeX << 1); + let y3 = y1 + (this.$$PrimeY << 1); + let z3 = z1 + (this.$$PrimeZ << 1); return ( - FastNoise.#CubicLerp( - FastNoise.#CubicLerp( - FastNoise.#CubicLerp( - this.#ValCoordR3(seed, x0, y0, z0), - this.#ValCoordR3(seed, x1, y0, z0), - this.#ValCoordR3(seed, x2, y0, z0), - this.#ValCoordR3(seed, x3, y0, z0), + FastNoise.$$CubicLerp( + FastNoise.$$CubicLerp( + FastNoise.$$CubicLerp( + this.$$ValCoordR3(seed, x0, y0, z0), + this.$$ValCoordR3(seed, x1, y0, z0), + this.$$ValCoordR3(seed, x2, y0, z0), + this.$$ValCoordR3(seed, x3, y0, z0), xs ), - FastNoise.#CubicLerp( - this.#ValCoordR3(seed, x0, y1, z0), - this.#ValCoordR3(seed, x1, y1, z0), - this.#ValCoordR3(seed, x2, y1, z0), - this.#ValCoordR3(seed, x3, y1, z0), + FastNoise.$$CubicLerp( + this.$$ValCoordR3(seed, x0, y1, z0), + this.$$ValCoordR3(seed, x1, y1, z0), + this.$$ValCoordR3(seed, x2, y1, z0), + this.$$ValCoordR3(seed, x3, y1, z0), xs ), - FastNoise.#CubicLerp( - this.#ValCoordR3(seed, x0, y2, z0), - this.#ValCoordR3(seed, x1, y2, z0), - this.#ValCoordR3(seed, x2, y2, z0), - this.#ValCoordR3(seed, x3, y2, z0), + FastNoise.$$CubicLerp( + this.$$ValCoordR3(seed, x0, y2, z0), + this.$$ValCoordR3(seed, x1, y2, z0), + this.$$ValCoordR3(seed, x2, y2, z0), + this.$$ValCoordR3(seed, x3, y2, z0), xs ), - FastNoise.#CubicLerp( - this.#ValCoordR3(seed, x0, y3, z0), - this.#ValCoordR3(seed, x1, y3, z0), - this.#ValCoordR3(seed, x2, y3, z0), - this.#ValCoordR3(seed, x3, y3, z0), + FastNoise.$$CubicLerp( + this.$$ValCoordR3(seed, x0, y3, z0), + this.$$ValCoordR3(seed, x1, y3, z0), + this.$$ValCoordR3(seed, x2, y3, z0), + this.$$ValCoordR3(seed, x3, y3, z0), xs ), ys ), - FastNoise.#CubicLerp( - FastNoise.#CubicLerp( - this.#ValCoordR3(seed, x0, y0, z1), - this.#ValCoordR3(seed, x1, y0, z1), - this.#ValCoordR3(seed, x2, y0, z1), - this.#ValCoordR3(seed, x3, y0, z1), + FastNoise.$$CubicLerp( + FastNoise.$$CubicLerp( + this.$$ValCoordR3(seed, x0, y0, z1), + this.$$ValCoordR3(seed, x1, y0, z1), + this.$$ValCoordR3(seed, x2, y0, z1), + this.$$ValCoordR3(seed, x3, y0, z1), xs ), - FastNoise.#CubicLerp( - this.#ValCoordR3(seed, x0, y1, z1), - this.#ValCoordR3(seed, x1, y1, z1), - this.#ValCoordR3(seed, x2, y1, z1), - this.#ValCoordR3(seed, x3, y1, z1), + FastNoise.$$CubicLerp( + this.$$ValCoordR3(seed, x0, y1, z1), + this.$$ValCoordR3(seed, x1, y1, z1), + this.$$ValCoordR3(seed, x2, y1, z1), + this.$$ValCoordR3(seed, x3, y1, z1), xs ), - FastNoise.#CubicLerp( - this.#ValCoordR3(seed, x0, y2, z1), - this.#ValCoordR3(seed, x1, y2, z1), - this.#ValCoordR3(seed, x2, y2, z1), - this.#ValCoordR3(seed, x3, y2, z1), + FastNoise.$$CubicLerp( + this.$$ValCoordR3(seed, x0, y2, z1), + this.$$ValCoordR3(seed, x1, y2, z1), + this.$$ValCoordR3(seed, x2, y2, z1), + this.$$ValCoordR3(seed, x3, y2, z1), xs ), - FastNoise.#CubicLerp( - this.#ValCoordR3(seed, x0, y3, z1), - this.#ValCoordR3(seed, x1, y3, z1), - this.#ValCoordR3(seed, x2, y3, z1), - this.#ValCoordR3(seed, x3, y3, z1), + FastNoise.$$CubicLerp( + this.$$ValCoordR3(seed, x0, y3, z1), + this.$$ValCoordR3(seed, x1, y3, z1), + this.$$ValCoordR3(seed, x2, y3, z1), + this.$$ValCoordR3(seed, x3, y3, z1), xs ), ys ), - FastNoise.#CubicLerp( - FastNoise.#CubicLerp( - this.#ValCoordR3(seed, x0, y0, z2), - this.#ValCoordR3(seed, x1, y0, z2), - this.#ValCoordR3(seed, x2, y0, z2), - this.#ValCoordR3(seed, x3, y0, z2), + FastNoise.$$CubicLerp( + FastNoise.$$CubicLerp( + this.$$ValCoordR3(seed, x0, y0, z2), + this.$$ValCoordR3(seed, x1, y0, z2), + this.$$ValCoordR3(seed, x2, y0, z2), + this.$$ValCoordR3(seed, x3, y0, z2), xs ), - FastNoise.#CubicLerp( - this.#ValCoordR3(seed, x0, y1, z2), - this.#ValCoordR3(seed, x1, y1, z2), - this.#ValCoordR3(seed, x2, y1, z2), - this.#ValCoordR3(seed, x3, y1, z2), + FastNoise.$$CubicLerp( + this.$$ValCoordR3(seed, x0, y1, z2), + this.$$ValCoordR3(seed, x1, y1, z2), + this.$$ValCoordR3(seed, x2, y1, z2), + this.$$ValCoordR3(seed, x3, y1, z2), xs ), - FastNoise.#CubicLerp( - this.#ValCoordR3(seed, x0, y2, z2), - this.#ValCoordR3(seed, x1, y2, z2), - this.#ValCoordR3(seed, x2, y2, z2), - this.#ValCoordR3(seed, x3, y2, z2), + FastNoise.$$CubicLerp( + this.$$ValCoordR3(seed, x0, y2, z2), + this.$$ValCoordR3(seed, x1, y2, z2), + this.$$ValCoordR3(seed, x2, y2, z2), + this.$$ValCoordR3(seed, x3, y2, z2), xs ), - FastNoise.#CubicLerp( - this.#ValCoordR3(seed, x0, y3, z2), - this.#ValCoordR3(seed, x1, y3, z2), - this.#ValCoordR3(seed, x2, y3, z2), - this.#ValCoordR3(seed, x3, y3, z2), + FastNoise.$$CubicLerp( + this.$$ValCoordR3(seed, x0, y3, z2), + this.$$ValCoordR3(seed, x1, y3, z2), + this.$$ValCoordR3(seed, x2, y3, z2), + this.$$ValCoordR3(seed, x3, y3, z2), xs ), ys ), - FastNoise.#CubicLerp( - FastNoise.#CubicLerp( - this.#ValCoordR3(seed, x0, y0, z3), - this.#ValCoordR3(seed, x1, y0, z3), - this.#ValCoordR3(seed, x2, y0, z3), - this.#ValCoordR3(seed, x3, y0, z3), + FastNoise.$$CubicLerp( + FastNoise.$$CubicLerp( + this.$$ValCoordR3(seed, x0, y0, z3), + this.$$ValCoordR3(seed, x1, y0, z3), + this.$$ValCoordR3(seed, x2, y0, z3), + this.$$ValCoordR3(seed, x3, y0, z3), xs ), - FastNoise.#CubicLerp( - this.#ValCoordR3(seed, x0, y1, z3), - this.#ValCoordR3(seed, x1, y1, z3), - this.#ValCoordR3(seed, x2, y1, z3), - this.#ValCoordR3(seed, x3, y1, z3), + FastNoise.$$CubicLerp( + this.$$ValCoordR3(seed, x0, y1, z3), + this.$$ValCoordR3(seed, x1, y1, z3), + this.$$ValCoordR3(seed, x2, y1, z3), + this.$$ValCoordR3(seed, x3, y1, z3), xs ), - FastNoise.#CubicLerp( - this.#ValCoordR3(seed, x0, y2, z3), - this.#ValCoordR3(seed, x1, y2, z3), - this.#ValCoordR3(seed, x2, y2, z3), - this.#ValCoordR3(seed, x3, y2, z3), + FastNoise.$$CubicLerp( + this.$$ValCoordR3(seed, x0, y2, z3), + this.$$ValCoordR3(seed, x1, y2, z3), + this.$$ValCoordR3(seed, x2, y2, z3), + this.$$ValCoordR3(seed, x3, y2, z3), xs ), - FastNoise.#CubicLerp( - this.#ValCoordR3(seed, x0, y3, z3), - this.#ValCoordR3(seed, x1, y3, z3), - this.#ValCoordR3(seed, x2, y3, z3), - this.#ValCoordR3(seed, x3, y3, z3), + FastNoise.$$CubicLerp( + this.$$ValCoordR3(seed, x0, y3, z3), + this.$$ValCoordR3(seed, x1, y3, z3), + this.$$ValCoordR3(seed, x2, y3, z3), + this.$$ValCoordR3(seed, x3, y3, z3), xs ), ys @@ -2250,22 +2250,22 @@ class FastNoise { * @param {number} y * @returns {number} */ - #SingleValueR2(seed, x, y) { + $$SingleValueR2(seed, x, y) { let x0 = Math.floor(x); let y0 = Math.floor(y); - let xs = FastNoise.#InterpHermite(x - x0); - let ys = FastNoise.#InterpHermite(y - y0); + let xs = FastNoise.$$InterpHermite(x - x0); + let ys = FastNoise.$$InterpHermite(y - y0); - x0 *= this.#PrimeX; - y0 *= this.#PrimeY; - let x1 = x0 + this.#PrimeX; - let y1 = y0 + this.#PrimeY; + x0 *= this.$$PrimeX; + y0 *= this.$$PrimeY; + let x1 = x0 + this.$$PrimeX; + let y1 = y0 + this.$$PrimeY; - let xf0 = FastNoise.#Lerp(this.#ValCoordR2(seed, x0, y0), this.#ValCoordR2(seed, x1, y0), xs); - let xf1 = FastNoise.#Lerp(this.#ValCoordR2(seed, x0, y1), this.#ValCoordR2(seed, x1, y1), xs); + let xf0 = FastNoise.$$Lerp(this.$$ValCoordR2(seed, x0, y0), this.$$ValCoordR2(seed, x1, y0), xs); + let xf1 = FastNoise.$$Lerp(this.$$ValCoordR2(seed, x0, y1), this.$$ValCoordR2(seed, x1, y1), xs); - return FastNoise.#Lerp(xf0, xf1, ys); + return FastNoise.$$Lerp(xf0, xf1, ys); } /** @@ -2276,53 +2276,53 @@ class FastNoise { * @param {number} z * @returns {number} */ - #SingleValueR3(seed, x, y, z) { + $$SingleValueR3(seed, x, y, z) { let x0 = Math.floor(x); let y0 = Math.floor(y); let z0 = Math.floor(z); - let xs = FastNoise.#InterpHermite(x - x0); - let ys = FastNoise.#InterpHermite(y - y0); - let zs = FastNoise.#InterpHermite(z - z0); + let xs = FastNoise.$$InterpHermite(x - x0); + let ys = FastNoise.$$InterpHermite(y - y0); + let zs = FastNoise.$$InterpHermite(z - z0); - x0 *= this.#PrimeX; - y0 *= this.#PrimeY; - z0 *= this.#PrimeZ; - let x1 = x0 + this.#PrimeX; - let y1 = y0 + this.#PrimeY; - let z1 = z0 + this.#PrimeZ; + x0 *= this.$$PrimeX; + y0 *= this.$$PrimeY; + z0 *= this.$$PrimeZ; + let x1 = x0 + this.$$PrimeX; + let y1 = y0 + this.$$PrimeY; + let z1 = z0 + this.$$PrimeZ; - let xf00 = FastNoise.#Lerp( - this.#ValCoordR3(seed, x0, y0, z0), - this.#ValCoordR3(seed, x1, y0, z0), + let xf00 = FastNoise.$$Lerp( + this.$$ValCoordR3(seed, x0, y0, z0), + this.$$ValCoordR3(seed, x1, y0, z0), xs ); - let xf10 = FastNoise.#Lerp( - this.#ValCoordR3(seed, x0, y1, z0), - this.#ValCoordR3(seed, x1, y1, z0), + let xf10 = FastNoise.$$Lerp( + this.$$ValCoordR3(seed, x0, y1, z0), + this.$$ValCoordR3(seed, x1, y1, z0), xs ); - let xf01 = FastNoise.#Lerp( - this.#ValCoordR3(seed, x0, y0, z1), - this.#ValCoordR3(seed, x1, y0, z1), + let xf01 = FastNoise.$$Lerp( + this.$$ValCoordR3(seed, x0, y0, z1), + this.$$ValCoordR3(seed, x1, y0, z1), xs ); - let xf11 = FastNoise.#Lerp( - this.#ValCoordR3(seed, x0, y1, z1), - this.#ValCoordR3(seed, x1, y1, z1), + let xf11 = FastNoise.$$Lerp( + this.$$ValCoordR3(seed, x0, y1, z1), + this.$$ValCoordR3(seed, x1, y1, z1), xs ); - let yf0 = FastNoise.#Lerp(xf00, xf10, ys); - let yf1 = FastNoise.#Lerp(xf01, xf11, ys); + let yf0 = FastNoise.$$Lerp(xf00, xf10, ys); + let yf1 = FastNoise.$$Lerp(xf01, xf11, ys); - return FastNoise.#Lerp(yf0, yf1, zs); + return FastNoise.$$Lerp(yf0, yf1, zs); } /** * @private */ - #DoSingleDomainWarp() { + $$DoSingleDomainWarp() { /** * * @param {number} seed @@ -2333,9 +2333,9 @@ class FastNoise { * @param {number} y */ let R2 = (seed, amp, freq, coord, x, y) => { - switch (this.#DomainWarpType) { + switch (this.$$DomainWarpType) { case FastNoise.DomainWarpType.OpenSimplex2: - this.#SingleDomainWarpOpenSimplex2Gradient( + this.$$SingleDomainWarpOpenSimplex2Gradient( seed, amp * 38.283687591552734375, freq, @@ -2346,7 +2346,7 @@ class FastNoise { ); break; case FastNoise.DomainWarpType.OpenSimplex2Reduced: - this.#SingleDomainWarpOpenSimplex2Gradient( + this.$$SingleDomainWarpOpenSimplex2Gradient( seed, amp * 16.0, freq, @@ -2357,7 +2357,7 @@ class FastNoise { ); break; case FastNoise.DomainWarpType.BasicGrid: - this.#SingleDomainWarpBasicGrid(seed, amp, freq, coord, x, y); + this.$$SingleDomainWarpBasicGrid(seed, amp, freq, coord, x, y); break; } }; @@ -2373,9 +2373,9 @@ class FastNoise { * @param {number} z */ let R3 = (seed, amp, freq, coord, x, y, z) => { - switch (this.#DomainWarpType) { + switch (this.$$DomainWarpType) { case FastNoise.DomainWarpType.OpenSimplex2: - this.#SingleDomainWarpOpenSimplex2Gradient( + this.$$SingleDomainWarpOpenSimplex2Gradient( seed, amp * 32.69428253173828125, freq, @@ -2387,7 +2387,7 @@ class FastNoise { ); break; case FastNoise.DomainWarpType.OpenSimplex2Reduced: - this.#SingleDomainWarpOpenSimplex2Gradient( + this.$$SingleDomainWarpOpenSimplex2Gradient( seed, amp * 7.71604938271605, freq, @@ -2399,7 +2399,7 @@ class FastNoise { ); break; case FastNoise.DomainWarpType.BasicGrid: - this.#SingleDomainWarpBasicGrid(seed, amp, freq, coord, x, y, z); + this.$$SingleDomainWarpBasicGrid(seed, amp, freq, coord, x, y, z); break; } }; @@ -2424,19 +2424,19 @@ class FastNoise { /** * @private */ - #DomainWarpSingle() { + $$DomainWarpSingle() { /** * * @param {Vector2} coord */ let R2 = coord => { - let seed = this.#Seed; - let amp = this.#DomainWarpAmp * this.#FractalBounding; - let freq = this.#Frequency; + let seed = this.$$Seed; + let amp = this.$$DomainWarpAmp * this.$$FractalBounding; + let freq = this.$$Frequency; let xs = coord.x; let ys = coord.y; - switch (this.#DomainWarpType) { + switch (this.$$DomainWarpType) { case FastNoise.DomainWarpType.OpenSimplex2: case FastNoise.DomainWarpType.OpenSimplex2Reduced: const SQRT3 = 1.7320508075688772935274463415059; @@ -2449,7 +2449,7 @@ class FastNoise { break; } - this.#DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); + this.$$DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); }; /** @@ -2457,14 +2457,14 @@ class FastNoise { * @param {Vector3} coord */ let R3 = coord => { - let seed = this.#Seed; - let amp = this.#DomainWarpAmp * this.#FractalBounding; - let freq = this.#Frequency; + let seed = this.$$Seed; + let amp = this.$$DomainWarpAmp * this.$$FractalBounding; + let freq = this.$$Frequency; let xs = coord.x; let ys = coord.y; let zs = coord.z; - switch (this.#WarpTransformType3D) { + switch (this.$$WarpTransformType3D) { case FastNoise.TransformType3D.ImproveXYPlanes: { let xy = xs + ys; @@ -2497,7 +2497,7 @@ class FastNoise { break; } - this.#DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); + this.$$DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); }; if (arguments.length === 1 && arguments[0] instanceof Vector2) { @@ -2509,20 +2509,20 @@ class FastNoise { } } - #DomainWarpFractalProgressive() { + $$DomainWarpFractalProgressive() { /** * * @param {Vector2} coord */ let R2 = coord => { - let seed = this.#Seed; - let amp = this.#DomainWarpAmp * this.#FractalBounding; - let freq = this.#Frequency; + let seed = this.$$Seed; + let amp = this.$$DomainWarpAmp * this.$$FractalBounding; + let freq = this.$$Frequency; - for (let i = 0; i < this.#Octaves; i++) { + for (let i = 0; i < this.$$Octaves; i++) { let xs = coord.x; let ys = coord.y; - switch (this.#DomainWarpType) { + switch (this.$$DomainWarpType) { case FastNoise.DomainWarpType.OpenSimplex2: case FastNoise.DomainWarpType.OpenSimplex2Reduced: const SQRT3 = 1.7320508075688772935274463415059; @@ -2535,11 +2535,11 @@ class FastNoise { break; } - this.#DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); + this.$$DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); seed++; - amp *= this.#Gain; - freq *= this.#Lacunarity; + amp *= this.$$Gain; + freq *= this.$$Lacunarity; } }; @@ -2548,15 +2548,15 @@ class FastNoise { * @param {Vector3} coord */ let R3 = coord => { - let seed = this.#Seed; - let amp = this.#DomainWarpAmp * this.#FractalBounding; - let freq = this.#Frequency; + let seed = this.$$Seed; + let amp = this.$$DomainWarpAmp * this.$$FractalBounding; + let freq = this.$$Frequency; - for (let i = 0; i < this.#Octaves; i++) { + for (let i = 0; i < this.$$Octaves; i++) { let xs = coord.x; let ys = coord.y; let zs = coord.z; - switch (this.#WarpTransformType3D) { + switch (this.$$WarpTransformType3D) { case FastNoise.TransformType3D.ImproveXYPlanes: { let xy = xs + ys; @@ -2590,11 +2590,11 @@ class FastNoise { break; } - this.#DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); + this.$$DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); seed++; - amp *= this.#Gain; - freq *= this.#Lacunarity; + amp *= this.$$Gain; + freq *= this.$$Lacunarity; } }; @@ -2610,7 +2610,7 @@ class FastNoise { /** * @private */ - #DomainWarpFractalIndependent() { + $$DomainWarpFractalIndependent() { /** * * @param {Vector2} coord @@ -2618,7 +2618,7 @@ class FastNoise { let R2 = coord => { let xs = coord.x; let ys = coord.y; - switch (this.#DomainWarpType) { + switch (this.$$DomainWarpType) { case FastNoise.DomainWarpType.OpenSimplex2: case FastNoise.DomainWarpType.OpenSimplex2Reduced: const SQRT3 = 1.7320508075688772935274463415059; @@ -2630,16 +2630,16 @@ class FastNoise { default: break; } - let seed = this.#Seed; - let amp = this.#DomainWarpAmp * this.#FractalBounding; - let freq = this.#Frequency; + let seed = this.$$Seed; + let amp = this.$$DomainWarpAmp * this.$$FractalBounding; + let freq = this.$$Frequency; - for (let i = 0; i < this.#Octaves; i++) { - this.#DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); + for (let i = 0; i < this.$$Octaves; i++) { + this.$$DoSingleDomainWarp(seed, amp, freq, coord, xs, ys); seed++; - amp *= this.#Gain; - freq *= this.#Lacunarity; + amp *= this.$$Gain; + freq *= this.$$Lacunarity; } }; @@ -2651,7 +2651,7 @@ class FastNoise { let xs = coord.x; let ys = coord.y; let zs = coord.z; - switch (this.#WarpTransformType3D) { + switch (this.$$WarpTransformType3D) { case FastNoise.TransformType3D.ImproveXYPlanes: { let xy = xs + ys; @@ -2685,15 +2685,15 @@ class FastNoise { break; } - let seed = this.#Seed; - let amp = this.#DomainWarpAmp * this.#FractalBounding; - let freq = this.#Frequency; - for (let i = 0; i < this.#Octaves; i++) { - this.#DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); + let seed = this.$$Seed; + let amp = this.$$DomainWarpAmp * this.$$FractalBounding; + let freq = this.$$Frequency; + for (let i = 0; i < this.$$Octaves; i++) { + this.$$DoSingleDomainWarp(seed, amp, freq, coord, xs, ys, zs); seed++; - amp *= this.#Gain; - freq *= this.#Lacunarity; + amp *= this.$$Gain; + freq *= this.$$Lacunarity; } }; @@ -2709,7 +2709,7 @@ class FastNoise { /** * @private */ - #SingleDomainWarpBasicGrid() { + $$SingleDomainWarpBasicGrid() { /** * * @param {number} seed @@ -2727,28 +2727,28 @@ class FastNoise { let x0 = Math.floor(xf); let y0 = Math.floor(yf); - let xs = FastNoise.#InterpHermite(xf - x0); - let ys = FastNoise.#InterpHermite(yf - y0); + let xs = FastNoise.$$InterpHermite(xf - x0); + let ys = FastNoise.$$InterpHermite(yf - y0); - x0 *= this.#PrimeX; - y0 *= this.#PrimeY; - let x1 = x0 + this.#PrimeX; - let y1 = y0 + this.#PrimeY; + x0 *= this.$$PrimeX; + y0 *= this.$$PrimeY; + let x1 = x0 + this.$$PrimeX; + let y1 = y0 + this.$$PrimeY; - let hash0 = this.#HashR2(seed, x0, y0) & (255 << 1); - let hash1 = this.#HashR2(seed, x1, y0) & (255 << 1); + let hash0 = this.$$HashR2(seed, x0, y0) & (255 << 1); + let hash1 = this.$$HashR2(seed, x1, y0) & (255 << 1); - let lx0x = FastNoise.#Lerp(this.#RandVecs2D[hash0], this.#RandVecs2D[hash1], xs); - let ly0x = FastNoise.#Lerp(this.#RandVecs2D[hash0 | 1], this.#RandVecs2D[hash1 | 1], xs); + let lx0x = FastNoise.$$Lerp(this.$$RandVecs2D[hash0], this.$$RandVecs2D[hash1], xs); + let ly0x = FastNoise.$$Lerp(this.$$RandVecs2D[hash0 | 1], this.$$RandVecs2D[hash1 | 1], xs); - hash0 = this.#HashR2(seed, x0, y1) & (255 << 1); - hash1 = this.#HashR2(seed, x1, y1) & (255 << 1); + hash0 = this.$$HashR2(seed, x0, y1) & (255 << 1); + hash1 = this.$$HashR2(seed, x1, y1) & (255 << 1); - let lx1x = FastNoise.#Lerp(this.#RandVecs2D[hash0], this.#RandVecs2D[hash1], xs); - let ly1x = FastNoise.#Lerp(this.#RandVecs2D[hash0 | 1], this.#RandVecs2D[hash1 | 1], xs); + let lx1x = FastNoise.$$Lerp(this.$$RandVecs2D[hash0], this.$$RandVecs2D[hash1], xs); + let ly1x = FastNoise.$$Lerp(this.$$RandVecs2D[hash0 | 1], this.$$RandVecs2D[hash1 | 1], xs); - coord.x += FastNoise.#Lerp(lx0x, lx1x, ys) * warpAmp; - coord.y += FastNoise.#Lerp(ly0x, ly1x, ys) * warpAmp; + coord.x += FastNoise.$$Lerp(lx0x, lx1x, ys) * warpAmp; + coord.y += FastNoise.$$Lerp(ly0x, ly1x, ys) * warpAmp; }; /** @@ -2770,52 +2770,52 @@ class FastNoise { let y0 = Math.floor(yf); let z0 = Math.floor(zf); - let xs = FastNoise.#InterpHermite(xf - x0); - let ys = FastNoise.#InterpHermite(yf - y0); - let zs = FastNoise.#InterpHermite(zf - z0); + let xs = FastNoise.$$InterpHermite(xf - x0); + let ys = FastNoise.$$InterpHermite(yf - y0); + let zs = FastNoise.$$InterpHermite(zf - z0); - x0 *= this.#PrimeX; - y0 *= this.#PrimeY; - z0 *= this.#PrimeZ; - let x1 = x0 + this.#PrimeX; - let y1 = y0 + this.#PrimeY; - let z1 = z0 + this.#PrimeZ; + x0 *= this.$$PrimeX; + y0 *= this.$$PrimeY; + z0 *= this.$$PrimeZ; + let x1 = x0 + this.$$PrimeX; + let y1 = y0 + this.$$PrimeY; + let z1 = z0 + this.$$PrimeZ; - let hash0 = this.#HashR3(seed, x0, y0, z0) & (255 << 2); - let hash1 = this.#HashR3(seed, x1, y0, z0) & (255 << 2); + let hash0 = this.$$HashR3(seed, x0, y0, z0) & (255 << 2); + let hash1 = this.$$HashR3(seed, x1, y0, z0) & (255 << 2); - let lx0x = FastNoise.#Lerp(this.#RandVecs3D[hash0], this.#RandVecs3D[hash1], xs); - let ly0x = FastNoise.#Lerp(this.#RandVecs3D[hash0 | 1], this.#RandVecs3D[hash1 | 1], xs); - let lz0x = FastNoise.#Lerp(this.#RandVecs3D[hash0 | 2], this.#RandVecs3D[hash1 | 2], xs); + let lx0x = FastNoise.$$Lerp(this.$$RandVecs3D[hash0], this.$$RandVecs3D[hash1], xs); + let ly0x = FastNoise.$$Lerp(this.$$RandVecs3D[hash0 | 1], this.$$RandVecs3D[hash1 | 1], xs); + let lz0x = FastNoise.$$Lerp(this.$$RandVecs3D[hash0 | 2], this.$$RandVecs3D[hash1 | 2], xs); - hash0 = this.#HashR3(seed, x0, y1, z0) & (255 << 2); - hash1 = this.#HashR3(seed, x1, y1, z0) & (255 << 2); + hash0 = this.$$HashR3(seed, x0, y1, z0) & (255 << 2); + hash1 = this.$$HashR3(seed, x1, y1, z0) & (255 << 2); - let lx1x = FastNoise.#Lerp(this.#RandVecs3D[hash0], this.#RandVecs3D[hash1], xs); - let ly1x = FastNoise.#Lerp(this.#RandVecs3D[hash0 | 1], this.#RandVecs3D[hash1 | 1], xs); - let lz1x = FastNoise.#Lerp(this.#RandVecs3D[hash0 | 2], this.#RandVecs3D[hash1 | 2], xs); + let lx1x = FastNoise.$$Lerp(this.$$RandVecs3D[hash0], this.$$RandVecs3D[hash1], xs); + let ly1x = FastNoise.$$Lerp(this.$$RandVecs3D[hash0 | 1], this.$$RandVecs3D[hash1 | 1], xs); + let lz1x = FastNoise.$$Lerp(this.$$RandVecs3D[hash0 | 2], this.$$RandVecs3D[hash1 | 2], xs); - let lx0y = FastNoise.#Lerp(lx0x, lx1x, ys); - let ly0y = FastNoise.#Lerp(ly0x, ly1x, ys); - let lz0y = FastNoise.#Lerp(lz0x, lz1x, ys); + let lx0y = FastNoise.$$Lerp(lx0x, lx1x, ys); + let ly0y = FastNoise.$$Lerp(ly0x, ly1x, ys); + let lz0y = FastNoise.$$Lerp(lz0x, lz1x, ys); - hash0 = this.#HashR3(seed, x0, y0, z1) & (255 << 2); - hash1 = this.#HashR3(seed, x1, y0, z1) & (255 << 2); + hash0 = this.$$HashR3(seed, x0, y0, z1) & (255 << 2); + hash1 = this.$$HashR3(seed, x1, y0, z1) & (255 << 2); - lx0x = FastNoise.#Lerp(this.#RandVecs3D[hash0], this.#RandVecs3D[hash1], xs); - ly0x = FastNoise.#Lerp(this.#RandVecs3D[hash0 | 1], this.#RandVecs3D[hash1 | 1], xs); - lz0x = FastNoise.#Lerp(this.#RandVecs3D[hash0 | 2], this.#RandVecs3D[hash1 | 2], xs); + lx0x = FastNoise.$$Lerp(this.$$RandVecs3D[hash0], this.$$RandVecs3D[hash1], xs); + ly0x = FastNoise.$$Lerp(this.$$RandVecs3D[hash0 | 1], this.$$RandVecs3D[hash1 | 1], xs); + lz0x = FastNoise.$$Lerp(this.$$RandVecs3D[hash0 | 2], this.$$RandVecs3D[hash1 | 2], xs); - hash0 = this.#HashR3(seed, x0, y1, z1) & (255 << 2); - hash1 = this.#HashR3(seed, x1, y1, z1) & (255 << 2); + hash0 = this.$$HashR3(seed, x0, y1, z1) & (255 << 2); + hash1 = this.$$HashR3(seed, x1, y1, z1) & (255 << 2); - lx1x = FastNoise.#Lerp(this.#RandVecs3D[hash0], this.#RandVecs3D[hash1], xs); - ly1x = FastNoise.#Lerp(this.#RandVecs3D[hash0 | 1], this.#RandVecs3D[hash1 | 1], xs); - lz1x = FastNoise.#Lerp(this.#RandVecs3D[hash0 | 2], this.#RandVecs3D[hash1 | 2], xs); + lx1x = FastNoise.$$Lerp(this.$$RandVecs3D[hash0], this.$$RandVecs3D[hash1], xs); + ly1x = FastNoise.$$Lerp(this.$$RandVecs3D[hash0 | 1], this.$$RandVecs3D[hash1 | 1], xs); + lz1x = FastNoise.$$Lerp(this.$$RandVecs3D[hash0 | 2], this.$$RandVecs3D[hash1 | 2], xs); - coord.x += FastNoise.#Lerp(lx0y, FastNoise.#Lerp(lx0x, lx1x, ys), zs) * warpAmp; - coord.y += FastNoise.#Lerp(ly0y, FastNoise.#Lerp(ly0x, ly1x, ys), zs) * warpAmp; - coord.z += FastNoise.#Lerp(lz0y, FastNoise.#Lerp(lz0x, lz1x, ys), zs) * warpAmp; + coord.x += FastNoise.$$Lerp(lx0y, FastNoise.$$Lerp(lx0x, lx1x, ys), zs) * warpAmp; + coord.y += FastNoise.$$Lerp(ly0y, FastNoise.$$Lerp(ly0x, ly1x, ys), zs) * warpAmp; + coord.z += FastNoise.$$Lerp(lz0y, FastNoise.$$Lerp(lz0x, lz1x, ys), zs) * warpAmp; }; if (arguments.length === 6 && arguments[3] instanceof Vector2) { @@ -2838,7 +2838,7 @@ class FastNoise { /** * @private */ - #SingleDomainWarpOpenSimplex2Gradient() { + $$SingleDomainWarpOpenSimplex2Gradient() { /** * * @param {number} seed @@ -2865,8 +2865,8 @@ class FastNoise { let x0 = xi - t; let y0 = yi - t; - i *= this.#PrimeX; - j *= this.#PrimeY; + i *= this.$$PrimeX; + j *= this.$$PrimeY; let vx, vy; vx = vy = 0; @@ -2876,18 +2876,18 @@ class FastNoise { let aaaa = a * a * (a * a); let xo, yo; if (outGradOnly) { - let hash = this.#HashR2(seed, i, j) & (255 << 1); - xo = this.#RandVecs2D[hash]; - yo = this.#RandVecs2D[hash | 1]; + let hash = this.$$HashR2(seed, i, j) & (255 << 1); + xo = this.$$RandVecs2D[hash]; + yo = this.$$RandVecs2D[hash | 1]; } else { - let hash = this.#HashR2(seed, i, j); + let hash = this.$$HashR2(seed, i, j); let index1 = hash & (127 << 1); let index2 = (hash >> 7) & (255 << 1); - let xg = this.#Gradients2D[index1]; - let yg = this.#Gradients2D[index1 | 1]; + let xg = this.$$Gradients2D[index1]; + let yg = this.$$Gradients2D[index1 | 1]; let value = x0 * xg + y0 * yg; - let xgo = this.#RandVecs2D[index2]; - let ygo = this.#RandVecs2D[index2 | 1]; + let xgo = this.$$RandVecs2D[index2]; + let ygo = this.$$RandVecs2D[index2 | 1]; xo = value * xgo; yo = value * ygo; } @@ -2902,18 +2902,18 @@ class FastNoise { let cccc = c * c * (c * c); let xo, yo; if (outGradOnly) { - let hash = this.#HashR2(seed, i + this.#PrimeX, j + this.#PrimeY) & (255 << 1); - xo = this.#RandVecs2D[hash]; - yo = this.#RandVecs2D[hash | 1]; + let hash = this.$$HashR2(seed, i + this.$$PrimeX, j + this.$$PrimeY) & (255 << 1); + xo = this.$$RandVecs2D[hash]; + yo = this.$$RandVecs2D[hash | 1]; } else { - let hash = this.#HashR2(seed, i + this.#PrimeX, j + this.#PrimeY); + let hash = this.$$HashR2(seed, i + this.$$PrimeX, j + this.$$PrimeY); let index1 = hash & (127 << 1); let index2 = (hash >> 7) & (255 << 1); - let xg = this.#Gradients2D[index1]; - let yg = this.#Gradients2D[index1 | 1]; + let xg = this.$$Gradients2D[index1]; + let yg = this.$$Gradients2D[index1 | 1]; let value = x2 * xg + y2 * yg; - let xgo = this.#RandVecs2D[index2]; - let ygo = this.#RandVecs2D[index2 | 1]; + let xgo = this.$$RandVecs2D[index2]; + let ygo = this.$$RandVecs2D[index2 | 1]; xo = value * xgo; yo = value * ygo; } @@ -2929,18 +2929,18 @@ class FastNoise { let bbbb = b * b * (b * b); let xo, yo; if (outGradOnly) { - let hash = this.#HashR2(seed, i, j + this.#PrimeY) & (255 << 1); - xo = this.#RandVecs2D[hash]; - yo = this.#RandVecs2D[hash | 1]; + let hash = this.$$HashR2(seed, i, j + this.$$PrimeY) & (255 << 1); + xo = this.$$RandVecs2D[hash]; + yo = this.$$RandVecs2D[hash | 1]; } else { - let hash = this.#HashR2(seed, i, j + this.#PrimeY); + let hash = this.$$HashR2(seed, i, j + this.$$PrimeY); let index1 = hash & (127 << 1); let index2 = (hash >> 7) & (255 << 1); - let xg = this.#Gradients2D[index1]; - let yg = this.#Gradients2D[index1 | 1]; + let xg = this.$$Gradients2D[index1]; + let yg = this.$$Gradients2D[index1 | 1]; let value = x1 * xg + y1 * yg; - let xgo = this.#RandVecs2D[index2]; - let ygo = this.#RandVecs2D[index2 | 1]; + let xgo = this.$$RandVecs2D[index2]; + let ygo = this.$$RandVecs2D[index2 | 1]; xo = value * xgo; yo = value * ygo; } @@ -2955,18 +2955,18 @@ class FastNoise { let bbbb = b * b * (b * b); let xo, yo; if (outGradOnly) { - let hash = this.#HashR2(seed, i + this.#PrimeX, j) & (255 << 1); - xo = this.#RandVecs2D[hash]; - yo = this.#RandVecs2D[hash | 1]; + let hash = this.$$HashR2(seed, i + this.$$PrimeX, j) & (255 << 1); + xo = this.$$RandVecs2D[hash]; + yo = this.$$RandVecs2D[hash | 1]; } else { - let hash = this.#HashR2(seed, i + this.#PrimeX, j); + let hash = this.$$HashR2(seed, i + this.$$PrimeX, j); let index1 = hash & (127 << 1); let index2 = (hash >> 7) & (255 << 1); - let xg = this.#Gradients2D[index1]; - let yg = this.#Gradients2D[index1 | 1]; + let xg = this.$$Gradients2D[index1]; + let yg = this.$$Gradients2D[index1 | 1]; let value = x1 * xg + y1 * yg; - let xgo = this.#RandVecs2D[index2]; - let ygo = this.#RandVecs2D[index2 | 1]; + let xgo = this.$$RandVecs2D[index2]; + let ygo = this.$$RandVecs2D[index2 | 1]; xo = value * xgo; yo = value * ygo; } @@ -3010,9 +3010,9 @@ class FastNoise { let ay0 = yNSign * -y0; let az0 = zNSign * -z0; - i *= this.#PrimeX; - j *= this.#PrimeY; - k *= this.#PrimeZ; + i *= this.$$PrimeX; + j *= this.$$PrimeY; + k *= this.$$PrimeZ; let vx, vy, vz; vx = vy = vz = 0; @@ -3023,21 +3023,21 @@ class FastNoise { let aaaa = a * a * (a * a); let xo, yo, zo; if (outGradOnly) { - let hash = this.#HashR3(seed, i, j, k) & (255 << 2); - xo = this.#RandVecs3D[hash]; - yo = this.#RandVecs3D[hash | 1]; - zo = this.#RandVecs3D[hash | 2]; + let hash = this.$$HashR3(seed, i, j, k) & (255 << 2); + xo = this.$$RandVecs3D[hash]; + yo = this.$$RandVecs3D[hash | 1]; + zo = this.$$RandVecs3D[hash | 2]; } else { - let hash = this.#HashR3(seed, i, j, k); + let hash = this.$$HashR3(seed, i, j, k); let index1 = hash & (63 << 2); let index2 = (hash >> 6) & (255 << 2); - let xg = this.#Gradients3D[index1]; - let yg = this.#Gradients3D[index1 | 1]; - let zg = this.#Gradients3D[index1 | 2]; + let xg = this.$$Gradients3D[index1]; + let yg = this.$$Gradients3D[index1 | 1]; + let zg = this.$$Gradients3D[index1 | 2]; let value = x0 * xg + y0 * yg + z0 * zg; - let xgo = this.#RandVecs3D[index2]; - let ygo = this.#RandVecs3D[index2 | 1]; - let zgo = this.#RandVecs3D[index2 | 2]; + let xgo = this.$$RandVecs3D[index2]; + let ygo = this.$$RandVecs3D[index2 | 1]; + let zgo = this.$$RandVecs3D[index2 | 2]; xo = value * xgo; yo = value * ygo; zo = value * zgo; @@ -3058,15 +3058,15 @@ class FastNoise { if (ax0 >= ay0 && ax0 >= az0) { x1 += xNSign; b = b + ax0 + ax0; - i1 -= xNSign * this.#PrimeX; + i1 -= xNSign * this.$$PrimeX; } else if (ay0 > ax0 && ay0 >= az0) { y1 += yNSign; b = b + ay0 + ay0; - j1 -= yNSign * this.#PrimeY; + j1 -= yNSign * this.$$PrimeY; } else { z1 += zNSign; b = b + az0 + az0; - k1 -= zNSign * this.#PrimeZ; + k1 -= zNSign * this.$$PrimeZ; } if (b > 1) { @@ -3074,21 +3074,21 @@ class FastNoise { let bbbb = b * b * (b * b); let xo, yo, zo; if (outGradOnly) { - let hash = this.#HashR3(seed, i1, j1, k1) & (255 << 2); - xo = this.#RandVecs3D[hash]; - yo = this.#RandVecs3D[hash | 1]; - zo = this.#RandVecs3D[hash | 2]; + let hash = this.$$HashR3(seed, i1, j1, k1) & (255 << 2); + xo = this.$$RandVecs3D[hash]; + yo = this.$$RandVecs3D[hash | 1]; + zo = this.$$RandVecs3D[hash | 2]; } else { - let hash = this.#HashR3(seed, i1, j1, k1); + let hash = this.$$HashR3(seed, i1, j1, k1); let index1 = hash & (63 << 2); let index2 = (hash >> 6) & (255 << 2); - let xg = this.#Gradients3D[index1]; - let yg = this.#Gradients3D[index1 | 1]; - let zg = this.#Gradients3D[index1 | 2]; + let xg = this.$$Gradients3D[index1]; + let yg = this.$$Gradients3D[index1 | 1]; + let zg = this.$$Gradients3D[index1 | 2]; let value = x1 * xg + y1 * yg + z1 * zg; - let xgo = this.#RandVecs3D[index2]; - let ygo = this.#RandVecs3D[index2 | 1]; - let zgo = this.#RandVecs3D[index2 | 2]; + let xgo = this.$$RandVecs3D[index2]; + let ygo = this.$$RandVecs3D[index2 | 1]; + let zgo = this.$$RandVecs3D[index2 | 2]; xo = value * xgo; yo = value * ygo; zo = value * zgo; @@ -3110,9 +3110,9 @@ class FastNoise { a += 0.75 - ax0 - (ay0 + az0); - i += (xNSign >> 1) & this.#PrimeX; - j += (yNSign >> 1) & this.#PrimeY; - k += (zNSign >> 1) & this.#PrimeZ; + i += (xNSign >> 1) & this.$$PrimeX; + j += (yNSign >> 1) & this.$$PrimeY; + k += (zNSign >> 1) & this.$$PrimeZ; xNSign = -xNSign; yNSign = -yNSign; diff --git a/packages/physics/src/resources/decorators/entity-list.js b/packages/physics/src/resources/decorators/entity-list.js index ee86f8d..0f987e7 100644 --- a/packages/physics/src/resources/decorators/entity-list.js +++ b/packages/physics/src/resources/decorators/entity-list.js @@ -1,6 +1,6 @@ export default (EntityList) => class PhysicsEntityList extends EntityList { - #world; + $$world; constructor() { super(); @@ -10,7 +10,7 @@ export default (EntityList) => class PhysicsEntityList extends EntityList { onEntityAdded(entity) { // eslint-disable-next-line no-param-reassign - entity.world = this.#world; + entity.world = this.$$world; } // eslint-disable-next-line class-methods-use-this @@ -27,7 +27,7 @@ export default (EntityList) => class PhysicsEntityList extends EntityList { entity.world = world; } } - this.#world = world; + this.$$world = world; } }; diff --git a/packages/physics/src/resources/decorators/tiles.js b/packages/physics/src/resources/decorators/tiles.js index 44f99ec..46b0152 100644 --- a/packages/physics/src/resources/decorators/tiles.js +++ b/packages/physics/src/resources/decorators/tiles.js @@ -6,11 +6,11 @@ import PolygonShape from '@avocado/physics/shape/polygon'; export default (Tiles) => class PhysicsTiles extends Tiles { - #bodies = []; + $$bodies = []; - #impassable = {}; + $$impassable = {}; - #world; + $$world; constructor() { super(); @@ -18,27 +18,27 @@ export default (Tiles) => class PhysicsTiles extends Tiles { } addBodies() { - if (!this.#world) { + if (!this.$$world) { return; } - const hulls = this.indexHulls(this.#impassable); + const hulls = this.indexHulls(this.$$impassable); for (let i = 0; i < hulls.length; ++i) { const scaled = []; for (let j = 0; j < hulls[i].length; ++j) { scaled.push(Vector.mul(hulls[i][j], this.tileSize)); } const [vertices, position] = Vertice.localize(scaled); - const body = this.#world.createBody(new PolygonShape({position, vertices})); + const body = this.$$world.createBody(new PolygonShape({position, vertices})); body.static = true; - this.#bodies.push(body); - this.#world.addBody(body); + this.$$bodies.push(body); + this.$$world.addBody(body); } } async load(json = {}) { await super.load(json); const {impassable = []} = json; - this.#impassable = new Set(impassable); + this.$$impassable = new Set(impassable); } onTilesUpdate() { @@ -47,17 +47,17 @@ export default (Tiles) => class PhysicsTiles extends Tiles { } removeBodies() { - if (this.#bodies.length > 0 && this.#world) { - for (let i = 0; i < this.#bodies.length; i++) { - this.#world.removeBody(this.#bodies[i]); + if (this.$$bodies.length > 0 && this.$$world) { + for (let i = 0; i < this.$$bodies.length; i++) { + this.$$world.removeBody(this.$$bodies[i]); } - this.#bodies = []; + this.$$bodies = []; } } set world(world) { this.removeBodies(); - this.#world = world; + this.$$world = world; this.addBodies(); } diff --git a/packages/physics/src/shape/polygon.js b/packages/physics/src/shape/polygon.js index f3aba19..b4f2943 100644 --- a/packages/physics/src/shape/polygon.js +++ b/packages/physics/src/shape/polygon.js @@ -4,14 +4,14 @@ import Shape from './shape'; export default class PolygonShape extends Shape { - #cachedTranslatedVertices; + $$cachedTranslatedVertices; - #vertices; + $$vertices; constructor(shape) { super(shape); - this.#cachedTranslatedVertices = []; - this.#vertices = []; + this.$$cachedTranslatedVertices = []; + this.$$vertices = []; this.on([ 'parentOriginChanged', 'parentRotationChanged', @@ -40,13 +40,13 @@ export default class PolygonShape extends Shape { } get aabb() { - if (0 === this.#vertices.length) { + if (0 === this.$$vertices.length) { return [0, 0, 0, 0]; } const min = [Infinity, Infinity]; const max = [-Infinity, -Infinity]; - for (let i = 0; i < this.#cachedTranslatedVertices.length; i++) { - const vertice = this.#cachedTranslatedVertices[i]; + for (let i = 0; i < this.$$cachedTranslatedVertices.length; i++) { + const vertice = this.$$cachedTranslatedVertices[i]; min[0] = vertice[0] < min[0] ? vertice[0] : min[0]; min[1] = vertice[1] < min[1] ? vertice[1] : min[1]; max[0] = vertice[0] > max[0] ? vertice[0] : max[0]; @@ -65,18 +65,18 @@ export default class PolygonShape extends Shape { const rotation = this.rotation + parentRotation; const parentScale = this.parent ? this.parent.scale : 1; const scale = this.scale * parentScale; - this.#cachedTranslatedVertices = this.#vertices.map((vertice) => ( + this.$$cachedTranslatedVertices = this.$$vertices.map((vertice) => ( Vertice.translate(vertice, origin, rotation, scale) )); this.emit('aabbChanged'); } get vertices() { - return this.#cachedTranslatedVertices; + return this.$$cachedTranslatedVertices; } set vertices(vertices) { - this.#vertices = [...vertices]; + this.$$vertices = [...vertices]; this.emit('verticesChanged'); } diff --git a/packages/physics/src/traits/collider.js b/packages/physics/src/traits/collider.js index 9b16216..80b50c6 100644 --- a/packages/physics/src/traits/collider.js +++ b/packages/physics/src/traits/collider.js @@ -9,22 +9,22 @@ const decorate = compose( export default (flecks) => class Collider extends decorate(Trait) { - #collidesWithGroups = []; + $$collidesWithGroups = []; - #collisionGroup = ''; + $$collisionGroup = ''; - #doesNotCollideWith = []; + $$doesNotCollideWith = []; - #isCollidingWith = []; + $$isCollidingWith = []; - #isSensor = false; + $$isSensor = false; constructor() { super(); ({ - collidesWithGroups: this.#collidesWithGroups, - collisionGroup: this.#collisionGroup, - isSensor: this.#isSensor, + collidesWithGroups: this.$$collidesWithGroups, + collisionGroup: this.$$collisionGroup, + isSensor: this.$$isSensor, } = this.constructor.defaultParams()); } @@ -107,21 +107,21 @@ export default (flecks) => class Collider extends decorate(Trait) { } get collisionGroup() { - return this.#collisionGroup; + return this.$$collisionGroup; } get collidesWithGroups() { - return this.#collidesWithGroups; + return this.$$collidesWithGroups; } indexOfCollidingEntity(entity) { - return this.#isCollidingWith.findIndex( + return this.$$isCollidingWith.findIndex( ({entity: collisionEntity}) => entity === collisionEntity, ); } get isCollidingWith() { - return this.#isCollidingWith; + return this.$$isCollidingWith; } isCollidingWithEntity(entity) { @@ -129,7 +129,7 @@ export default (flecks) => class Collider extends decorate(Trait) { } get isSensor() { - return this.#isSensor; + return this.$$isSensor; } async load(json) { @@ -139,9 +139,9 @@ export default (flecks) => class Collider extends decorate(Trait) { collisionGroup, isSensor, } = this.params; - this.#collidesWithGroups = collidesWithGroups; - this.#collisionGroup = collisionGroup; - this.#isSensor = isSensor; + this.$$collidesWithGroups = collidesWithGroups; + this.$$collisionGroup = collisionGroup; + this.$$isSensor = isSensor; } async pushCollisionTickingPromise(codeOrUri, other, incident) { @@ -154,11 +154,11 @@ export default (flecks) => class Collider extends decorate(Trait) { } releaseAllCollisions() { - for (let i = 0; i < this.#isCollidingWith.length; i++) { - const {entity} = this.#isCollidingWith[i]; + for (let i = 0; i < this.$$isCollidingWith.length; i++) { + const {entity} = this.$$isCollidingWith[i]; entity.emit('collisionEnd', this.entity); } - this.#isCollidingWith = []; + this.$$isCollidingWith = []; } // eslint-disable-next-line class-methods-use-this @@ -176,7 +176,7 @@ export default (flecks) => class Collider extends decorate(Trait) { collisionEnd: (other, incident) => { const index = this.indexOfCollidingEntity(other); if (-1 !== index) { - this.#isCollidingWith.splice(index, 1); + this.$$isCollidingWith.splice(index, 1); if (this.params.collisionEndScript) { this.pushCollisionTickingPromise(this.params.collisionEndScript, other, incident); } @@ -186,7 +186,7 @@ export default (flecks) => class Collider extends decorate(Trait) { collisionStart: (other, incident) => { const index = this.indexOfCollidingEntity(other); if (-1 === index) { - this.#isCollidingWith.push({ + this.$$isCollidingWith.push({ entity: other, incident, }); @@ -210,25 +210,25 @@ export default (flecks) => class Collider extends decorate(Trait) { if (!this.entity.isColliding || !entity.isColliding) { return false; } - if (-1 !== this.#doesNotCollideWith.indexOf(entity)) { + if (-1 !== this.$$doesNotCollideWith.indexOf(entity)) { return false; } const {collisionGroup} = entity; - return -1 !== this.#collidesWithGroups.indexOf(collisionGroup); + return -1 !== this.$$collidesWithGroups.indexOf(collisionGroup); }, doesNotCollideWith: (entity) => !this.entity.collidesWith(entity), setDoesCollideWith: (entity) => { - const index = this.#doesNotCollideWith.indexOf(entity); + const index = this.$$doesNotCollideWith.indexOf(entity); if (-1 !== index) { - this.#doesNotCollideWith.splice(index, 1); + this.$$doesNotCollideWith.splice(index, 1); } }, setDoesNotCollideWith: (entity) => { - if (-1 === this.#doesNotCollideWith.indexOf(entity)) { - this.#doesNotCollideWith.push(entity); + if (-1 === this.$$doesNotCollideWith.indexOf(entity)) { + this.$$doesNotCollideWith.push(entity); } }, }; diff --git a/packages/physics/src/traits/emitted.js b/packages/physics/src/traits/emitted.js index baf16c8..f55da94 100644 --- a/packages/physics/src/traits/emitted.js +++ b/packages/physics/src/traits/emitted.js @@ -7,39 +7,39 @@ const decorate = compose( export default (flecks) => class Emitted extends decorate(Trait) { - #alphaStart; + $$alphaStart; - #alphaEnd; + $$alphaEnd; - #force; + $$force; - #mass; + $$mass; - #position; + $$position; - #rotationStart; + $$rotationStart; - #rotationAdd; + $$rotationAdd; - #ttl; + $$ttl; - #velocityAngle; + $$velocityAngle; - #velocityMagnitude; + $$velocityMagnitude; constructor(...args) { super(...args); const params = this.constructor.defaultParams(); - this.#alphaStart = new Range(params.alpha.start); - this.#alphaEnd = new Range(params.alpha.end); - this.#force = new Vector.Range(params.force); - this.#mass = params.mass; - this.#position = null; - this.#rotationStart = new Range(params.rotation.start); - this.#rotationAdd = new Range(params.rotation.add); - this.#ttl = new Range(params.ttl); - this.#velocityAngle = new Range(params.velocity.angle); - this.#velocityMagnitude = new Range(params.velocity.magnitude); + this.$$alphaStart = new Range(params.alpha.start); + this.$$alphaEnd = new Range(params.alpha.end); + this.$$force = new Vector.Range(params.force); + this.$$mass = params.mass; + this.$$position = null; + this.$$rotationStart = new Range(params.rotation.start); + this.$$rotationAdd = new Range(params.rotation.add); + this.$$ttl = new Range(params.ttl); + this.$$velocityAngle = new Range(params.velocity.angle); + this.$$velocityMagnitude = new Range(params.velocity.magnitude); } static behaviorTypes() { @@ -85,21 +85,21 @@ export default (flecks) => class Emitted extends decorate(Trait) { async load(json) { await super.load(json); - this.#alphaStart = new Range(this.params.alpha.start); - this.#alphaEnd = new Range(this.params.alpha.end); - this.#force = new Vector.Range(this.params.force); - this.#mass = this.params.mass; + this.$$alphaStart = new Range(this.params.alpha.start); + this.$$alphaEnd = new Range(this.params.alpha.end); + this.$$force = new Vector.Range(this.params.force); + this.$$mass = this.params.mass; if (null !== this.params.position) { - this.#position = new Vector.Range(this.params.position); + this.$$position = new Vector.Range(this.params.position); } else { - this.#position = null; + this.$$position = null; } - this.#rotationStart = new Range(this.params.rotation.start); - this.#rotationAdd = new Range(this.params.rotation.add); - this.#ttl = new Range(this.params.ttl); - this.#velocityAngle = new Range(this.params.velocity.angle); - this.#velocityMagnitude = new Range(this.params.velocity.magnitude); + this.$$rotationStart = new Range(this.params.rotation.start); + this.$$rotationAdd = new Range(this.params.rotation.add); + this.$$ttl = new Range(this.params.ttl); + this.$$velocityAngle = new Range(this.params.velocity.angle); + this.$$velocityMagnitude = new Range(this.params.velocity.magnitude); } listeners() { @@ -121,25 +121,25 @@ export default (flecks) => class Emitted extends decorate(Trait) { return { particle: () => { - const position = null === this.#position ? null : this.#position.value(); - const force = this.#force.value(); + const position = null === this.$$position ? null : this.$$position.value(); + const force = this.$$force.value(); const particle = { alpha: { - start: this.#alphaStart.value(), - end: this.#alphaEnd.value(), + start: this.$$alphaStart.value(), + end: this.$$alphaEnd.value(), }, force, listed: this.params.listed, - mass: this.#mass, + mass: this.$$mass, position, rotation: { - start: this.#rotationStart.value(), - add: this.#rotationAdd.value(), + start: this.$$rotationStart.value(), + add: this.$$rotationAdd.value(), }, - ttl: this.#ttl.value(), + ttl: this.$$ttl.value(), velocity: { - angle: this.#velocityAngle.value(), - magnitude: this.#velocityMagnitude.value(), + angle: this.$$velocityAngle.value(), + magnitude: this.$$velocityMagnitude.value(), }, }; if (this.params.scale) { diff --git a/packages/physics/src/traits/emitter.js b/packages/physics/src/traits/emitter.js index 7e3ff96..5bca357 100644 --- a/packages/physics/src/traits/emitter.js +++ b/packages/physics/src/traits/emitter.js @@ -12,30 +12,30 @@ const decorate = compose( export default (flecks) => class Emitter extends decorate(Trait) { - #emissions = []; + $$emissions = []; - #emitter = new Proton.Emitter(); + $$emitter = new Proton.Emitter(); - #emitting = []; + $$emitting = []; - #onParticleDead; + $$onParticleDead; - #onParticleUpdate; + $$onParticleUpdate; - #particles = {}; + $$particles = {}; - #proton = new Proton(); + $$proton = new Proton(); - #streams = []; + $$streams = []; constructor() { super(); - this.#proton.addEmitter(this.#emitter); - this.#onParticleDead = this.onParticleDead.bind(this); - this.#onParticleUpdate = this.onParticleUpdate.bind(this); - this.#emitter.bindEvent = true; - this.#emitter.addEventListener('PARTICLE_DEAD', this.#onParticleDead); - this.#emitter.addEventListener('PARTICLE_UPDATE', this.#onParticleUpdate); + this.$$proton.addEmitter(this.$$emitter); + this.$$onParticleDead = this.onParticleDead.bind(this); + this.$$onParticleUpdate = this.onParticleUpdate.bind(this); + this.$$emitter.bindEvent = true; + this.$$emitter.addEventListener('PARTICLE_DEAD', this.$$onParticleDead); + this.$$emitter.addEventListener('PARTICLE_UPDATE', this.$$onParticleUpdate); } acceptPacket(packet) { @@ -48,7 +48,7 @@ export default (flecks) => class Emitter extends decorate(Trait) { cleanPackets() { super.cleanPackets(); - this.#emitting = []; + this.$$emitting = []; } static defaultParams() { @@ -77,20 +77,20 @@ export default (flecks) => class Emitter extends decorate(Trait) { const [key, particle] = paramParticles[i]; particles[key] = merge(particles[key] || {}, particle); } - this.#particles = particles; + this.$$particles = particles; } hooks() { const hooks = {}; hooks.afterDestructionTickers = () => (elapsed) => { - if (0 === this.#emitter.particles.length) { - this.#emitter.destroy(); + if (0 === this.$$emitter.particles.length) { + this.$$emitter.destroy(); return true; } this.tick(elapsed); return false; }; - hooks.destroy = () => () => 0 === this.#streams.length; + hooks.destroy = () => () => 0 === this.$$streams.length; return hooks; } @@ -152,7 +152,7 @@ export default (flecks) => class Emitter extends decorate(Trait) { ), ); } - const protonParticle = this.#emitter.createParticle( + const protonParticle = this.$$emitter.createParticle( initializers, behaviors, ); @@ -166,7 +166,7 @@ export default (flecks) => class Emitter extends decorate(Trait) { this.entity.list.addEntity(entity); } // Prime. - this.#onParticleUpdate(protonParticle); + this.$$onParticleUpdate(protonParticle); return entity; }, @@ -188,7 +188,7 @@ export default (flecks) => class Emitter extends decorate(Trait) { json, ); if (transmit && 'web' !== process.env.FLECKS_CORE_BUILD_TARGET) { - this.#emitting.push(augmentedJson); + this.$$emitting.push(augmentedJson); this.markAsDirty(); } const stream = K.stream((emitter) => { @@ -209,9 +209,9 @@ export default (flecks) => class Emitter extends decorate(Trait) { count -= 1; if (count > 0) { const removeEmission = () => { - const index = this.#emissions.indexOf(ticker); + const index = this.$$emissions.indexOf(ticker); if (-1 !== index) { - this.#emissions.splice(index, 1); + this.$$emissions.splice(index, 1); } emitter.end(); }; @@ -222,27 +222,27 @@ export default (flecks) => class Emitter extends decorate(Trait) { removeEmission(); } }); - this.#emissions.push(ticker); + this.$$emissions.push(ticker); } } }); - this.#streams.push(stream); + this.$$streams.push(stream); stream.onEnd(() => { - const index = this.#streams.indexOf(stream); - this.#streams.splice(index, 1); + const index = this.$$streams.indexOf(stream); + this.$$streams.splice(index, 1); }); return stream; }, emitParticle: (key, json = {}) => { - const particleJson = this.#particles[key]; + const particleJson = this.$$particles[key]; if (!particleJson) { return undefined; } return this.entity.emitParticleJson(merge(particleJson, json)); }, - jsonForParticle: (key, json = {}) => merge(this.#particles[key] || {}, json), + jsonForParticle: (key, json = {}) => merge(this.$$particles[key] || {}, json), }; } @@ -271,15 +271,15 @@ export default (flecks) => class Emitter extends decorate(Trait) { } packetsFor() { - return this.#emitting.length > 0 - ? [['EmitParticles', this.#emitting]] + return this.$$emitting.length > 0 + ? [['EmitParticles', this.$$emitting]] : []; } tick(elapsed) { - this.#emitter.update(elapsed); - for (let i = 0; i < this.#emissions.length; i++) { - this.#emissions[i].tick(elapsed); + this.$$emitter.update(elapsed); + for (let i = 0; i < this.$$emissions.length; i++) { + this.$$emissions[i].tick(elapsed); } } diff --git a/packages/physics/src/traits/physical.js b/packages/physics/src/traits/physical.js index ff41749..4c001ed 100644 --- a/packages/physics/src/traits/physical.js +++ b/packages/physics/src/traits/physical.js @@ -12,28 +12,28 @@ const decorate = compose( export default () => class Physical extends decorate(Trait) { - #body; + $$body; - #bodyView; + $$bodyView; - #world; + $$world; addToWorld() { - const world = this.#world; + const world = this.$$world; if (world) { const body = world.createBody(this.entity.shape); body.friction = this.entity.friction; world.associateBodyWithEntity(body, this.entity); body.setCollisionForEntity(this.entity); world.addBody(body); - this.#body = body; + this.$$body = body; if ('web' === process.env.FLECKS_CORE_BUILD_TARGET) { if (this.entity.is('Visible') && this.params.isDebugging) { - this.#bodyView = new BodyView(body); - this.#bodyView.position = Vector.scale(this.entity.position, -1); - this.#bodyView.visible = true; - this.#bodyView.zIndex = 101; - this.entity.addRasterChild(this.#bodyView); + this.$$bodyView = new BodyView(body); + this.$$bodyView.position = Vector.scale(this.entity.position, -1); + this.$$bodyView.visible = true; + this.$$bodyView.zIndex = 101; + this.entity.addRasterChild(this.$$bodyView); } } } @@ -63,7 +63,7 @@ export default () => class Physical extends decorate(Trait) { } get body() { - return this.#body; + return this.$$body; } static defaultParams() { @@ -101,19 +101,19 @@ export default () => class Physical extends decorate(Trait) { }, frictionChanged: () => { - if (this.#body) { - this.#body.friction = this.entity.friction; + if (this.$$body) { + this.$$body.friction = this.entity.friction; } }, positionChanged: () => { - if (this.#body) { - this.#body.position = this.entity.position; + if (this.$$body) { + this.$$body.position = this.entity.position; } }, removedFromRoom: () => { - if (this.#body) { + if (this.$$body) { this.removeFromWorld(); } }, @@ -125,14 +125,14 @@ export default () => class Physical extends decorate(Trait) { return { applyForce: (force) => { - if (this.#world && this.#body) { - this.#body.applyForce(force); + if (this.$$world && this.$$body) { + this.$$body.applyForce(force); } }, applyImpulse: (impulse) => { - if (this.#world && this.#body) { - this.#body.applyImpulse(impulse); + if (this.$$world && this.$$body) { + this.$$body.applyImpulse(impulse); } }, @@ -140,25 +140,25 @@ export default () => class Physical extends decorate(Trait) { } removeFromWorld() { - if (this.#world && this.#body) { - this.#world.removeBody(this.#body); + if (this.$$world && this.$$body) { + this.$$world.removeBody(this.$$body); } - this.#body = undefined; - if (this.#bodyView) { + this.$$body = undefined; + if (this.$$bodyView) { if (this.entity.is('Visible')) { - this.entity.removeRasterChild(this.#bodyView); + this.entity.removeRasterChild(this.$$bodyView); } - this.#bodyView.destroy(); + this.$$bodyView.destroy(); } - this.#bodyView = undefined; + this.$$bodyView = undefined; } set world(world) { - if (this.#world === world) { + if (this.$$world === world) { return; } this.removeFromWorld(); - this.#world = world; + this.$$world = world; this.addToWorld(); } diff --git a/packages/physics/src/traits/shaped.js b/packages/physics/src/traits/shaped.js index 4b51655..f584821 100644 --- a/packages/physics/src/traits/shaped.js +++ b/packages/physics/src/traits/shaped.js @@ -9,9 +9,9 @@ const decorate = compose( export default () => class Shaped extends decorate(Trait) { - #shape; + $$shape; - #shapeView; + $$shapeView; static defaultParams() { return { @@ -26,11 +26,11 @@ export default () => class Shaped extends decorate(Trait) { destroy() { super.destroy(); - this.#shape.destroy(); - if (this.#shapeView) { - this.entity.removeRasterChild(this.#shapeView); - this.#shapeView.destroy(); - this.#shapeView = undefined; + this.$$shape.destroy(); + if (this.$$shapeView) { + this.entity.removeRasterChild(this.$$shapeView); + this.$$shapeView.destroy(); + this.$$shapeView = undefined; } } @@ -40,11 +40,11 @@ export default () => class Shaped extends decorate(Trait) { traitAdded: () => { if ('web' === process.env.FLECKS_CORE_BUILD_TARGET) { if (this.entity.is('Visible') && this.params.isDebugging) { - if (!this.#shapeView) { - this.#shapeView = new ShapeView(this.entity.shape); - this.#shapeView.visible = false; - this.#shapeView.zIndex = 100; - this.entity.addRasterChild(this.#shapeView); + if (!this.$$shapeView) { + this.$$shapeView = new ShapeView(this.entity.shape); + this.$$shapeView.visible = false; + this.$$shapeView.zIndex = 100; + this.entity.addRasterChild(this.$$shapeView); } } } @@ -55,11 +55,11 @@ export default () => class Shaped extends decorate(Trait) { async load(json) { await super.load(json); - this.#shape = shapeFromJSON(this.params.shape); + this.$$shape = shapeFromJSON(this.params.shape); } get shape() { - return this.#shape; + return this.$$shape; } }; diff --git a/packages/s13n/src/serializer.js b/packages/s13n/src/serializer.js index 4f422af..88c0b71 100644 --- a/packages/s13n/src/serializer.js +++ b/packages/s13n/src/serializer.js @@ -3,37 +3,37 @@ class Cancellation extends Error {} export default class Serializer { - #pending = new Map(); + $$pending = new Map(); - #promises = new Map(); + $$promises = new Map(); create(id, creator) { const promise = creator.then(async (resource) => { - if (!this.#pending.has(id)) { + if (!this.$$pending.has(id)) { await resource.destroy(); throw new Cancellation(); } - this.#pending.delete(id); + this.$$pending.delete(id); return resource; }).catch((error) => { if (!(error instanceof Cancellation)) { throw error; } }); - this.#pending.set(id, () => this.#pending.delete(id)); - this.#promises.set(id, promise); + this.$$pending.set(id, () => this.$$pending.delete(id)); + this.$$promises.set(id, promise); return promise; } destroy(id) { // Cancel... - this.#pending.get(id)?.(); - this.#pending.delete(id); - this.#promises.delete(id); + this.$$pending.get(id)?.(); + this.$$pending.delete(id); + this.$$promises.delete(id); } later(id, fn) { - const promise = this.#promises.get(id); + const promise = this.$$promises.get(id); if (!promise) { return Promise.resolve(); } diff --git a/packages/sound/src/sound.js b/packages/sound/src/sound.js index 705fbb5..f92c52f 100644 --- a/packages/sound/src/sound.js +++ b/packages/sound/src/sound.js @@ -51,18 +51,18 @@ if ('web' === process.env.FLECKS_CORE_BUILD_TARGET) { export default class Sound extends JsonResource { - #audio; + $$audio; async load(json = {}) { await super.load(json); const {volume = 1} = json; const src = json.src || json.uri.replace('.sound.json', '.wav'); if ('web' !== process.env.FLECKS_CORE_BUILD_TARGET) { - this.#audio = new FakeAudio(); + this.$$audio = new FakeAudio(); return; } if (cache.has(src)) { - this.#audio = await cache.get(src); + this.$$audio = await cache.get(src); return; } const promise = new Promise((resolve, reject) => { @@ -83,16 +83,16 @@ export default class Sound extends JsonResource { }).catch(reject); }); cache.set(src, promise); - this.#audio = await promise; + this.$$audio = await promise; } pause() { - this.#audio.pause(); + this.$$audio.pause(); } play() { if ('web' === process.env.FLECKS_CORE_BUILD_TARGET) { - play(this.#audio, this.uri); + play(this.$$audio, this.uri); } } diff --git a/packages/sound/src/traits/audible.js b/packages/sound/src/traits/audible.js index a0ca446..837364a 100644 --- a/packages/sound/src/traits/audible.js +++ b/packages/sound/src/traits/audible.js @@ -7,9 +7,9 @@ const debug = D('@avocado/sound/audible'); export default () => class Audible extends Trait { - #playing = {}; + $$playing = {}; - #sounds = {}; + $$sounds = {}; acceptPacket(packet) { if ('PlaySound' === packet.constructor.type) { @@ -20,20 +20,20 @@ export default () => class Audible extends Trait { async addSounds(sounds) { return Promise.all( Object.entries(sounds).map(([key, sound]) => { - if (this.#sounds[key]) { + if (this.$$sounds[key]) { return undefined; } - this.#sounds[key] = Sound.load(sound).then((sound) => { - this.#sounds[key] = sound; + this.$$sounds[key] = Sound.load(sound).then((sound) => { + this.$$sounds[key] = sound; }); - return this.#sounds[key]; + return this.$$sounds[key]; }), ); } cleanPackets() { super.cleanPackets(); - this.#playing = {}; + this.$$playing = {}; } static defaultParams() { @@ -44,7 +44,7 @@ export default () => class Audible extends Trait { destroy() { super.destroy(); - Object.values(this.#sounds).forEach((sound) => { + Object.values(this.$$sounds).forEach((sound) => { Promise.resolve(sound).then((sound) => { sound.destroy(); }); @@ -69,19 +69,19 @@ export default () => class Audible extends Trait { methods() { return { - hasSound: (key) => !!this.#sounds[key], + hasSound: (key) => !!this.$$sounds[key], playSound: (key) => { debug('Checking %s', key); if (!this.entity.hasSound(key)) { try { - this.#sounds[key] = Sound.load({extends: key}) + this.$$sounds[key] = Sound.load({extends: key}) .then((sound) => { - this.#sounds[key] = sound; + this.$$sounds[key] = sound; return sound; }) .catch(() => { - delete this.#sounds[key]; + delete this.$$sounds[key]; }); this.playSound(key); } @@ -89,13 +89,13 @@ export default () => class Audible extends Trait { catch (error) {} } if ('web' === process.env.FLECKS_CORE_BUILD_TARGET) { - Promise.resolve(this.#sounds[key]).then((sound) => { + Promise.resolve(this.$$sounds[key]).then((sound) => { debug('Playing %s', key); sound.play(); }); } else { - this.#playing[key] = true; + this.$$playing[key] = true; this.markAsDirty(); } }, @@ -116,7 +116,7 @@ export default () => class Audible extends Trait { } packetsFor() { - return Object.keys(this.#playing).map((key) => ['PlaySound', {sound: key}]); + return Object.keys(this.$$playing).map((key) => ['PlaySound', {sound: key}]); } }; diff --git a/packages/timing/src/traits/animated.js b/packages/timing/src/traits/animated.js index a5cbc25..f2eb9e6 100644 --- a/packages/timing/src/traits/animated.js +++ b/packages/timing/src/traits/animated.js @@ -17,20 +17,20 @@ const decorate = compose( export default (flecks) => class Animated extends decorate(Trait) { - #animations = {}; + $$animations = {}; - #animationViews = {}; + $$animationViews = {}; - #cachedAabbs = {}; + $$cachedAabbs = {}; - #currentAnimation = ''; + $$currentAnimation = ''; - #forceUpdate = false; + $$forceUpdate = false; constructor() { super(); ({ - currentAnimation: this.#currentAnimation, + currentAnimation: this.$$currentAnimation, } = this.constructor.defaultParams()); } @@ -43,7 +43,7 @@ export default (flecks) => class Animated extends decorate(Trait) { } get animation() { - return this.#animations[this.#currentAnimation]; + return this.$$animations[this.$$currentAnimation]; } static defaultParams() { @@ -67,28 +67,28 @@ export default (flecks) => class Animated extends decorate(Trait) { destroy() { super.destroy(); - if (this.#animationViews) { - const animationViews = Object.entries(this.#animationViews); + if (this.$$animationViews) { + const animationViews = Object.entries(this.$$animationViews); for (let i = 0; i < animationViews.length; i++) { const [key, animationView] = animationViews[i]; this.hideAnimation(key); animationView.destroy(); } - this.#animationViews = undefined; + this.$$animationViews = undefined; } - const animations = Object.values(this.#animations); + const animations = Object.values(this.$$animations); for (let i = 0; i < animations.length; i++) { animations[i].destroy(); } - this.#animations = {}; - this.#cachedAabbs = {}; + this.$$animations = {}; + this.$$cachedAabbs = {}; } hideAnimation(key) { - if (!this.#animationViews) { + if (!this.$$animationViews) { return; } - const animationView = this.#animationViews[key]; + const animationView = this.$$animationViews[key]; if (!animationView) { return; } @@ -102,14 +102,14 @@ export default (flecks) => class Animated extends decorate(Trait) { return { visibleAabbs: () => { - const key = this.#currentAnimation; - if (key in this.#cachedAabbs) { - return this.#cachedAabbs[key]; + const key = this.$$currentAnimation; + if (key in this.$$cachedAabbs) { + return this.$$cachedAabbs[key]; } - if (!(key in this.#animations)) { + if (!(key in this.$$animations)) { return [0, 0, 0, 0]; } - const {frameSize} = this.#animations[key]; + const {frameSize} = this.$$animations[key]; const scaledSize = Vector.mul(frameSize, this.entity.visibleScale); const viewPosition = Vector.sub( this.offsetFor(key), @@ -120,7 +120,7 @@ export default (flecks) => class Animated extends decorate(Trait) { rectangle, Vector.sub(scaledSize, frameSize), ); - this.#cachedAabbs[key] = expanded; + this.$$cachedAabbs[key] = expanded; return expanded; }, @@ -138,16 +138,16 @@ export default (flecks) => class Animated extends decorate(Trait) { return { currentAnimationChanged: (oldKey, currentAnimation) => { - this.#currentAnimation = currentAnimation; + this.$$currentAnimation = currentAnimation; // Reset old animation. - if (oldKey in this.#animations) { - const oldAnimation = this.#animations[oldKey]; + if (oldKey in this.$$animations) { + const oldAnimation = this.$$animations[oldKey]; oldAnimation.reset(); } // Bounding box update. this.entity.scheduleBoundingBoxUpdate(); // Only client/graphics. - if (!this.#animationViews) { + if (!this.$$animationViews) { return; } // Swap the animation. @@ -157,7 +157,7 @@ export default (flecks) => class Animated extends decorate(Trait) { directionChanged: () => { // All animations track direction. - const animations = Object.values(this.#animations); + const animations = Object.values(this.$$animations); for (let i = 0; i < animations.length; i++) { animations[i].direction = this.entity.direction; } @@ -169,8 +169,8 @@ export default (flecks) => class Animated extends decorate(Trait) { traitAdded: () => { this.setSpriteScale(); - Object.entries(this.#animations).forEach(([key, animation]) => { - const method = key === this.#currentAnimation + Object.entries(this.$$animations).forEach(([key, animation]) => { + const method = key === this.$$currentAnimation ? 'showAnimation' : 'hideAnimation'; this[method](key); @@ -183,7 +183,7 @@ export default (flecks) => class Animated extends decorate(Trait) { }, visibleScaleChanged: () => { - this.#cachedAabbs = {}; + this.$$cachedAabbs = {}; this.setSpriteScale(); }, @@ -206,18 +206,18 @@ export default (flecks) => class Animated extends decorate(Trait) { // eslint-disable-next-line no-param-reassign animationView.position = this.offsetFor(key); }); - this.#animations = animations; - this.#animationViews = animationViews; + this.$$animations = animations; + this.$$animationViews = animationViews; } - this.#currentAnimation = this.state.currentAnimation; + this.$$currentAnimation = this.state.currentAnimation; } methods() { return { setAnimationRate: (rate) => { - if (this.#animations[this.#currentAnimation].frameRate !== rate) { - this.#animations[this.#currentAnimation].frameRate = rate; - this.#forceUpdate = true; + if (this.$$animations[this.$$currentAnimation].frameRate !== rate) { + this.$$animations[this.$$currentAnimation].frameRate = rate; + this.$$forceUpdate = true; } }, }; @@ -232,8 +232,8 @@ export default (flecks) => class Animated extends decorate(Trait) { packetsFor() { const {currentAnimation, isAnimating} = this.stateDifferences(); - if (this.#forceUpdate || currentAnimation || isAnimating) { - this.#forceUpdate = false; + if (this.$$forceUpdate || currentAnimation || isAnimating) { + this.$$forceUpdate = false; return [[ 'TraitUpdateAnimated', { @@ -247,20 +247,20 @@ export default (flecks) => class Animated extends decorate(Trait) { } setSpriteScale() { - if (!this.#animationViews) { + if (!this.$$animationViews) { return; } - const animationViews = Object.values(this.#animationViews); + const animationViews = Object.values(this.$$animationViews); for (let i = 0; i < animationViews.length; i++) { animationViews[i].scale = this.entity.visibleScale; } } showAnimation(key) { - if (!this.#animationViews) { + if (!this.$$animationViews) { return; } - const animationView = this.#animationViews[key]; + const animationView = this.$$animationViews[key]; if (!animationView) { return; } @@ -275,11 +275,11 @@ export default (flecks) => class Animated extends decorate(Trait) { return; } // Only tick current animation. - const currentAnimation = this.#currentAnimation; - if (!(currentAnimation in this.#animations)) { + const currentAnimation = this.$$currentAnimation; + if (!(currentAnimation in this.$$animations)) { return; } - const animation = this.#animations[currentAnimation]; + const animation = this.$$animations[currentAnimation]; const jitterAmount = this.jitterFor(currentAnimation); if (jitterAmount > 0) { const jitter = Math.random() * jitterAmount; diff --git a/packages/timing/src/traits/evolving.js b/packages/timing/src/traits/evolving.js index 91898bc..2eb3e1b 100644 --- a/packages/timing/src/traits/evolving.js +++ b/packages/timing/src/traits/evolving.js @@ -2,7 +2,7 @@ import {Trait} from '@avocado/traits'; export default () => class Evolving extends Trait { - #evolving; + $$evolving; static defaultParams() { return { @@ -15,11 +15,11 @@ export default () => class Evolving extends Trait { if (0 === Object.keys(this.params.lfo).length) { return; } - this.#evolving = this.entity.lfo(this.params.lfo); + this.$$evolving = this.entity.lfo(this.params.lfo); } tick(elapsed) { - this.#evolving.tick(elapsed); + this.$$evolving.tick(elapsed); } }; diff --git a/packages/topdown/src/resources/tiles.js b/packages/topdown/src/resources/tiles.js index d41f433..b075340 100644 --- a/packages/topdown/src/resources/tiles.js +++ b/packages/topdown/src/resources/tiles.js @@ -35,23 +35,23 @@ export default (flecks) => { ); return class Tiles extends decorate(JsonResource) { - #atlas = new Atlas(); + $$atlas = new Atlas(); - #data = new Uint16Array(); + $$data = new Uint16Array(); - #hasUpdates = false; + $$hasUpdates = false; - #packets = []; + $$packets = []; - #s13nId = 0; + $$s13nId = 0; - #tileImageUri; + $$tileImageUri; - #tileSize = [0, 0]; + $$tileSize = [0, 0]; - #updates = []; + $$updates = []; - #zIndex = 0; + $$zIndex = 0; acceptPacket(packet) { if ('TilesUpdate' === packet.constructor.type) { @@ -62,12 +62,12 @@ export default (flecks) => { } cleanPackets() { - this.#packets = []; - this.#updates = []; + this.$$packets = []; + this.$$updates = []; } destroy() { - this.#atlas.destroy(); + this.$$atlas.destroy(); } static indexHulls(indices, data, size) { @@ -132,7 +132,7 @@ export default (flecks) => { } indexHulls(indices) { - return this.constructor.indexHulls(indices, this.#data, this.area); + return this.constructor.indexHulls(indices, this.$$data, this.area); } async load(json) { @@ -149,37 +149,37 @@ export default (flecks) => { } if (data) { const {buffer, byteOffset, length} = inflate(Buffer.from(data, 'base64')); - this.#data = new Uint16Array(buffer, byteOffset, length / 2); + this.$$data = new Uint16Array(buffer, byteOffset, length / 2); } else if (area) { - this.#data = new Uint16Array(Vector.area(area)); + this.$$data = new Uint16Array(Vector.area(area)); } if (tileImageUri && tileSize) { - this.#tileSize = tileSize; - this.#tileImageUri = tileImageUri; - await this.#atlas.load({ + this.$$tileSize = tileSize; + this.$$tileImageUri = tileImageUri; + await this.$$atlas.load({ imageUri: tileImageUri, type: 'grid', size: tileSize, }); } if (s13nId) { - this.#s13nId = s13nId; + this.$$s13nId = s13nId; } if (zIndex > 0) { - this.#zIndex = zIndex; + this.$$zIndex = zIndex; } } packetsFor() { - if (0 === this.#updates.length) { + if (0 === this.$$updates.length) { return []; } - if (0 === this.#packets.length) { + if (0 === this.$$packets.length) { // TODO: merge? - for (let i = 0; i < this.#updates.length; i++) { - const [position, size, tiles] = this.#updates[i]; - this.#packets.push([ + for (let i = 0; i < this.$$updates.length; i++) { + const [position, size, tiles] = this.$$updates[i]; + this.$$packets.push([ 'TilesUpdate', { position, @@ -189,7 +189,7 @@ export default (flecks) => { ]); } } - return this.#packets; + return this.$$packets; } get rectangle() { @@ -197,19 +197,19 @@ export default (flecks) => { } get s13nId() { - return this.#s13nId; + return this.$$s13nId; } setTileAt([x, y], tile) { const [w, h] = this.area; const index = y * w + x; - if (x < 0 || x >= w || y < 0 || y >= h || this.#data[index] === tile) { + if (x < 0 || x >= w || y < 0 || y >= h || this.$$data[index] === tile) { return; } - this.#data[index] = tile; + this.$$data[index] = tile; if ('web' !== process.env.FLECKS_CORE_BUILD_TARGET) { - this.#updates.push([[x, y], [1, 1], [tile]]); - this.#hasUpdates = true; + this.$$updates.push([[x, y], [1, 1], [tile]]); + this.$$hasUpdates = true; } } @@ -225,7 +225,7 @@ export default (flecks) => { let j = 0; for (let l = 0; l < h; ++l) { for (let k = 0; k < w; ++k) { - slice[j] = x < 0 || x >= fw || y < 0 || y >= fh ? 0 : this.#data[i]; + slice[j] = x < 0 || x >= fw || y < 0 || y >= fh ? 0 : this.$$data[i]; x += 1; i += 1; j += 1; @@ -254,7 +254,7 @@ export default (flecks) => { for (let yy = 0; yy < h; ++yy) { for (let xx = 0; xx < w; ++xx) { if (sx >= 0 && sx < fw && sy >= 0 && sy < fh) { - this.#data[i] = tiles[j]; + this.$$data[i] = tiles[j]; isDirty = true; } i += 1; @@ -267,49 +267,49 @@ export default (flecks) => { sy += 1; } if (isDirty && 'web' !== process.env.FLECKS_CORE_BUILD_TARGET) { - this.#updates.push([[x, y], [w, h], tiles]); - this.#hasUpdates = true; + this.$$updates.push([[x, y], [w, h], tiles]); + this.$$hasUpdates = true; } } subimage(index) { - return this.#atlas.subimage(index); + return this.$$atlas.subimage(index); } tick() { - if (this.#hasUpdates) { + if (this.$$hasUpdates) { this.emit('update'); } - this.#hasUpdates = false; + this.$$hasUpdates = false; } tileAt([x, y]) { const [w, h] = this.area; - return x < 0 || x >= w || y < 0 || y >= h ? undefined : this.#data[y * w + x]; + return x < 0 || x >= w || y < 0 || y >= h ? undefined : this.$$data[y * w + x]; } get tileSize() { - return this.#tileSize; + return this.$$tileSize; } toNetwork() { return { ...this.toJSON(), - s13nId: this.#s13nId, + s13nId: this.$$s13nId, }; } toJSON() { return { area: this.area, - data: deflate(this.#data).toString('base64'), - tileSize: this.#tileSize, - ...(this.#tileImageUri ? {tileImageUri: this.#tileImageUri} : []), + data: deflate(this.$$data).toString('base64'), + tileSize: this.$$tileSize, + ...(this.$$tileImageUri ? {tileImageUri: this.$$tileImageUri} : []), }; } get zIndex() { - return this.#zIndex; + return this.$$zIndex; } }; diff --git a/packages/topdown/src/traits/followed.js b/packages/topdown/src/traits/followed.js index e79a90a..5fc6954 100644 --- a/packages/topdown/src/traits/followed.js +++ b/packages/topdown/src/traits/followed.js @@ -4,7 +4,7 @@ import Camera from '../camera'; export default (flecks) => class Followed extends Trait { - #camera = new Camera(); + $$camera = new Camera(); static defaultParams() { return { @@ -19,12 +19,12 @@ export default (flecks) => class Followed extends Trait { } get camera() { - return this.#camera; + return this.$$camera; } hotJSON() { return { - camera: this.#camera, + camera: this.$$camera, }; } @@ -42,9 +42,9 @@ export default (flecks) => class Followed extends Trait { await super.load(json); // @hot if (json.camera) { - this.#camera = json.camera; + this.$$camera = json.camera; } - this.#camera.viewSize = this.params.viewSize; + this.$$camera.viewSize = this.params.viewSize; this.updatePosition(); this.onRoomSizeChanged(); } @@ -52,12 +52,12 @@ export default (flecks) => class Followed extends Trait { onRoomSizeChanged() { const {room} = this.entity; if (room) { - this.#camera.areaSize = room.size; + this.$$camera.areaSize = room.size; } } renderTick(elapsed) { - this.#camera.tick(elapsed); + this.$$camera.tick(elapsed); } tick() { @@ -65,7 +65,7 @@ export default (flecks) => class Followed extends Trait { } updatePosition() { - this.#camera.position = this.entity.position; + this.$$camera.position = this.entity.position; } }; diff --git a/packages/traits/src/trait.js b/packages/traits/src/trait.js index 281cd45..5b5a0f8 100644 --- a/packages/traits/src/trait.js +++ b/packages/traits/src/trait.js @@ -2,18 +2,18 @@ import {JsonResource} from '@avocado/resource'; export default class Trait extends JsonResource { - #markedAsDirty = true; + $$markedAsDirty = true; - #memoizedListeners = undefined; + $$memoizedListeners = undefined; - #previousState = {}; + $$previousState = {}; constructor() { super(); const {constructor} = this; this.params = constructor.defaultParams(); this.state = constructor.defaultState(); - this.#previousState = JSON.parse(JSON.stringify(this.state)); + this.$$previousState = JSON.parse(JSON.stringify(this.state)); if (this.tick) { this.tick = this.tick.bind(this); } @@ -26,7 +26,7 @@ export default class Trait extends JsonResource { acceptPacket(packet) {} cleanPackets() { - if (!this.#markedAsDirty) { + if (!this.$$markedAsDirty) { return; } this.markAsClean(); @@ -60,7 +60,7 @@ export default class Trait extends JsonResource { } destroy() { - this.#memoizedListeners = undefined; + this.$$memoizedListeners = undefined; } // eslint-disable-next-line class-methods-use-this @@ -78,28 +78,28 @@ export default class Trait extends JsonResource { const {constructor} = this; this.params = constructor.defaultParamsWith(params); this.state = constructor.defaultStateWith(state); - this.#previousState = JSON.parse(JSON.stringify(this.state)); + this.$$previousState = JSON.parse(JSON.stringify(this.state)); } markAsClean() { const state = Object.entries(this.state); for (let i = 0; i < state.length; i++) { const [key, value] = state[i]; - this.#previousState[key] = value; + this.$$previousState[key] = value; } - this.#markedAsDirty = false; + this.$$markedAsDirty = false; } markAsDirty() { - this.#markedAsDirty = true; + this.$$markedAsDirty = true; this.entity.markAsDirty(); } memoizedListeners() { - if (!this.#memoizedListeners) { - this.#memoizedListeners = this.listeners(); + if (!this.$$memoizedListeners) { + this.$$memoizedListeners = this.listeners(); } - return this.#memoizedListeners; + return this.$$memoizedListeners; } // eslint-disable-next-line class-methods-use-this @@ -126,9 +126,9 @@ export default class Trait extends JsonResource { const state = Object.entries(this.state); for (let i = 0; i < state.length; i++) { const [key, value] = state[i]; - if (value !== this.#previousState[key]) { + if (value !== this.$$previousState[key]) { differences[key] = { - old: this.#previousState[key], + old: this.$$previousState[key], value, }; }