Skip to content

Commit 42a5af5

Browse files
committed
Collider Manager added, not fully implemented
-Auto sub-collider "hash" map gets created upon importing FBX with colliders for Floor, Walls, Wall Tops, & Room Warp Pads. -Adjusted some shader issues in ground shaders for Campfire & Field Environment
1 parent ec378d1 commit 42a5af5

File tree

24 files changed

+833
-138
lines changed

24 files changed

+833
-138
lines changed

Build/pxlNavStyle.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Public/index.htm

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
<!-- -- -- -- -->
4646

4747
<link type="text/css" rel="stylesheet" href="style/ProcStackStyle.css">
48-
<link type="text/css" rel="stylesheet" href="style/pxlNavStyle.css">
48+
<link type="text/css" rel="stylesheet" href="style/pxlNavStyle.min.css">
4949

5050

5151
<!-- -- -- -- -->
@@ -396,23 +396,39 @@
396396

397397
<br><br>
398398
<div ll-src='https://pxlmancer.com/show/learningGradients_84_opt.gif' ll-thumb='https://pxlmancer.com/show/learningGradients_84_th.jpg' ll-width='320' ll-height='320' class='lazyLoad gitPageImageStyle' alt='ESN Brain Wrinkling'></div>
399-
<span class="innerCenter">A different slice & settings for the same ESN I wrote.
399+
<span class="innerCenter">Different types of slices from the same ESN, just different input video.
400+
<div class='gitPageAboutMeSpacer'></div>
401+
Upper left is another video I made the AI is watching, upper right is shifts in detected movement,
402+
<br>Lower left is a slice of the brain's learned wrinkles, lower right is predicted movement.</span>
403+
<div class='gitPageAboutMeSpacer'></div>
404+
Currently it doesn't use the predicted movement for anything,
405+
<br>The next step would be introducing a base image to motion-transfer / referece.
406+
<div class='gitPageAboutMeSpacer'></div>
407+
So I'm just learnin' while watching my ai learnin'!
400408
<div class='gitPageAboutMeSpacer'></div>
401-
Upper left is another video I made the AI is watching, upper right is the brain's prediction,
402-
<br>Lower left is a slice of the brain's learned wrinkles, lower right the brain's prediction.
403409

404-
<br><br>With a "reservoir" of 15 times steps, you'll notice about every 15 frames the brain shifts.
410+
<br>With a "reservoir" of 15 times steps, you'll notice about every 15 frames the brain shifts.
405411
<br>By frame ~45, it's learned some patterns
406-
<br>The brain seems to then melt and rebuild itself to be predicting by frame ~70.
412+
<br>The brain seems to completely melt at ~75 and rebuild itself by ~95.
407413

408414
<br><br>It should be happenstance that the brain shifts when the reservoir fills,
409415
<br>Could mean I'm not correctly accounting for high p-values, outliers;
410-
<br>But it's detecting patterns in motion!</span>
416+
<br>But it's detecting patterns in motion!
411417
</span>
412418

413419
<br><img src='https://www.pxlmancer.com/show/learningGradients_84_brainSlice.png' class='gitPageImageStyle' alt='Custom ESN Learning Gradients' >
414420
<span class="innerCenter">A slice of the ESN's brain by frame 101 of watching the X pattern video.</span>
415421

422+
<br>Since I didn't have a good use case for the ESN in Python,
423+
<br>&nbsp;&nbsp; I built a similar ESM through C# in Unity to operate NPC's ability to learning player habbits.
424+
<br>The logic is pretty simple, so running by CPU is fine for now,
425+
<br>&nbsp;&nbsp; I'll likely look to move it to GPU in the future, if need be.
426+
<br>I set it up to learn less often when the player is in another room.
427+
<br>&nbsp;&nbsp; Thinking that I'd want to set up a "data transfer" between characters,
428+
<br>&nbsp;&nbsp;&nbsp;&nbsp; Gossip about the player.
429+
<br>&nbsp;&nbsp; But it's just cubes and spheres in Unity at the moment.
430+
431+
416432
<br><br>If you couldn't tell by now, I'm training my AIs on my own creations.
417433
<br>A personally made AI trained on personally made images / videos / photos / code / writing training data.
418434
<br>&nbsp;&nbsp; That means I can copyright my generations, right?
@@ -440,7 +456,7 @@
440456

441457
<canvas id="pxlNav-coreCanvas" height='1' width='1' class="pxlNavCoreCanvasStyle" ></canvas>
442458

443-
<script type="module" src="js/ProckStackGitio.js?v=2024-12-30"></script>
459+
<script type="module" src="js/ProckStackGitio.js?v=2025-1-2"></script>
444460

445461

446462
</body>

Public/style/pxlNavStyle.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Source/js/pxlNav.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// Core pxlNav Engine
3-
const pxlNavVersion = "0.0.17";
4-
// Written by Kevin Edzenga 2020;2024
3+
const pxlNavVersion = "0.0.18";
4+
// Written by Kevin Edzenga 2020;2024-2025
55

66
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
77
//
@@ -233,6 +233,13 @@ class pxlNav{
233233

234234
this.pxlEnv = new pxlBase.Environment( this.options, this.startingRoom, this.mobile );
235235
this.pxlDevice = new pxlBase.Device( projectTitle, pxlCore, this.mobile, this.autoCam );
236+
237+
// Default Grid Size 50, Collider Bounds as reference 1000.0
238+
// The reference bounds are used to scale down the grid size for smaller bbox colliders,
239+
// Helping with higher poly counts for performance
240+
this.pxlColliders = new pxlBase.Colliders( this.verbose, 50, 1000.0 );
241+
242+
236243
this.pxlCamera = new pxlBase.Camera();
237244
// Disable Free-Roam camera mode if static camera is enabled
238245
if( this.options["staticCamera"] ){
@@ -243,6 +250,8 @@ class pxlNav{
243250

244251
this.pxlGuiDraws = new pxlBase.GUI( this.verbose, projectTitle, this.folderDict["assetRoot"], this.folderDict["guiRoot"] );
245252

253+
// TODO : These should really be requested via pxlEnv methods, but for now...
254+
// Too many dependencies still to refactor, but it's cleaner than its ever been, so I'll take it!
246255
this.pxlQuality.setDependencies( this );
247256
this.pxlUtils.setDependencies( this );
248257
this.pxlFile.setDependencies( this );
@@ -251,6 +260,7 @@ class pxlNav{
251260
this.pxlEnv.setDependencies( this );
252261
this.pxlAnim.setDependencies( this );
253262
this.pxlDevice.setDependencies( this );
263+
this.pxlColliders.setDependencies( this );
254264
this.pxlCamera.setDependencies( this );
255265
this.pxlGuiDraws.setDependencies( this );
256266

Source/js/pxlNav/Environment.js

Lines changed: 6 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -329,49 +329,16 @@ export class Environment{
329329

330330
//this.buildSnow();
331331

332-
/*
333-
// Prevent Web Camera from booting
334-
if( this.pxlDevice.mobile || this.pxlAutoCam.enabled){
335-
this.pxlAutoCam.toggleAutoCam();
336-
this.fogMult.x = 1;
337-
if( ! this.pxlAutoCam.enabled ){
338-
this.pxlGuiDraws.toggleMobileWelcome(true);
339-
}else{
340-
this.postIntro=true;
341-
this.pxlCamera.colliderValid=true;
342-
this.pxlCamera.eventCheckStatus=true;
343-
this.pxlCamera.colliderShiftActive=true;
344-
this.pxlCamera.nearestFloorObjName="mobile";
345-
this.pxlCamera.colliderCurObjHit="AudioTrigger_2";
346-
this.pxlCamera.proximityScaleTrigger=true;
347-
this.exposureShiftActive=true;
348-
this.pxlAudio.setFadeActive( 1 );
349-
}
350-
}else{
351-
this.pxlGuiDraws.iconEvent( "click", this.pxlGuiDraws.hudIcons.helpIcon, "help" );
352-
}
353-
*/
354-
355-
/*
356-
// Prevent audio and video booting
357-
setTimeout( ()=>{
358-
this.pxlAudio.postBoot();
359-
360-
if( this.pxlDevice.mobile ){
361-
this.pxlAudio.djPlayerMuteToggle(true);
362-
}
363-
364-
if(this.pxlVideo){
365-
this.pxlVideo.postBoot('dj');
366-
}
367-
368-
}, 1000);
369-
*/
370332
}
371333

372334
postHelpIntro(){
335+
// If the device is a computer, without autocam, send player details to the server
336+
// TODO : This will need to be accessible from the room object and set-up networking as an extention
373337
if( !this.pxlDevice.mobile && !this.pxlAutoCam.enabled ){
374338
this.pxlCamera.jogServerMemory();
339+
340+
// If the device is a mobile, or autocam is enabled,
341+
// Trigger a valid collider to allow the camera to be placed.
375342
}else{
376343
this.pxlCamera.colliderValid=true;
377344
this.pxlCamera.eventCheckStatus=true;
@@ -381,6 +348,7 @@ export class Environment{
381348
this.pxlCamera.proximityScaleTrigger=true;
382349
this.exposureShiftActive=true;
383350

351+
// TODO : Media (audio, video, music) needs to be an setting on the pxlOptions object
384352
if( !this.pxlDevice.mobile ){
385353
this.pxlAudio.play();
386354
setTimeout( ()=>{
@@ -729,57 +697,6 @@ export class Environment{
729697
}
730698

731699

732-
buildSnow(){
733-
//sprite = ImageUtils.loadTexture( "textures/sprites/disc.png" );
734-
735-
let vertexCount = 12000; // Point Count
736-
let pScale = 12; // Point Base Scale
737-
738-
let geo = new BufferGeometry();
739-
let verts = [];
740-
let seeds = [];
741-
let atlasId = [];
742-
743-
const atlasGen=()=>{ return Math.floor( (Math.random() * 4000) % 4 )*.25; };
744-
745-
for( let x=0; x<vertexCount; ++x ){
746-
verts.push( 0,0,0 );
747-
seeds.push( (Math.random()),(Math.random()),(Math.random()*2-1), (Math.random()*.5+.5) );
748-
atlasId.push( atlasGen(), atlasGen() );
749-
}
750-
751-
let posAttribute = new Float32BufferAttribute( verts, 3 );
752-
let seedAttribute = new Float32BufferAttribute( seeds, 4 );
753-
let atlasAttribute = new Float32BufferAttribute( atlasId, 2 );
754-
//let idAttribute = new Uint8BufferAttribute( pId, 1 ); // ## would only be 0-65536; set up vector array for ids
755-
geo.setAttribute( 'position', posAttribute );
756-
geo.setAttribute( 'seeds', seedAttribute );
757-
geo.setAttribute( 'atlas', atlasAttribute );
758-
//geo.setAttribute( 'id', idAttribute );
759-
760-
let snowUniforms={
761-
snowTexture:{type:"t",value: this.pxlUtils.loadTexture( this.pxlUtils.assetRoot+"snow.jpg", 1, {"encoding":LinearSRGBColorSpace, "magFilter":NearestFilter, "minFilter":NearestMipmapNearestFilter} ) },
762-
pointScale:{type:"f",value: pScale*this.pxlQuality.screenResPerc },
763-
intensity:{type:"f",value:1.0},
764-
rate:{type:"f",value:.035},
765-
};
766-
console.log(this.pxlShaders.particles)
767-
let mtl = this.pxlFile.pxlShaderBuilder( snowUniforms, this.pxlShaders.particles.snowVert( this.mobile ), this.pxlShaders.particles.snowFrag() );
768-
mtl.side=DoubleSide;
769-
mtl.transparent=true;
770-
mtl.blending=AdditiveBlending;
771-
mtl.depthTest=true;
772-
mtl.depthWrite=false;
773-
774-
let snow = new Points( geo, mtl );
775-
snow.sortParticles = false;
776-
snow.frustumCulled = false;
777-
this.scene.add( snow );
778-
snow.layers.set(1);
779-
snow.pBaseScale=pScale;
780-
this.geoList['snow']=snow;
781-
}
782-
783700
// A screen filled plane to render outside of effect composer passes
784701
buildBackgroundObject( customUniforms={}, bgVert=null, bgFrag=null){
785702
let geo = new PlaneBufferGeometry();

Source/js/pxlNav/RoomClass.js

Lines changed: 124 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ import {
3232
} from "../libs/three/three.module.min.js";
3333
import { pxlPrincipledVert, pxlPrincipledFrag } from "./shaders/objects/PxlPrincipled.js";
3434

35+
import { COLLIDER_TYPE } from "./core/Enums.js";
36+
3537
class RoomEnvironment{
3638
constructor( roomName='CampfireEnvironment', assetPath=null, pxlFile=null, pxlAnim=null, pxlUtils=null, pxlDevice=null, pxlEnv=null, msRunner=null, camera=null, scene=null, cloud3dTexture=null ){
3739
this.roomName=roomName;
@@ -103,7 +105,6 @@ class RoomEnvironment{
103105
this.glassList=[]
104106
this.particleList={};
105107

106-
this.portalList={};
107108

108109
this.enableRaycast = false;
109110
this.hoverableExists=false;
@@ -116,12 +117,17 @@ class RoomEnvironment{
116117

117118
this.collidersExist=false;
118119
this.colliderActive=false;
120+
this.colliderHashMap={};
119121
this.colliderList={ 'noAxis':[], '11':[], '01':[], '10':[], '00':[] };
120122
this.antiColliderActive=false;
121123
this.antiColliderList={ 'noAxis':[], '11':[], '01':[], '10':[], '00':[] };
122124
this.antiColliderTopActive=false;
123125
this.antiColliderTopList={ 'noAxis':[], '11':[], '01':[], '10':[], '00':[] };
124126

127+
this.hasPortalExit=false;
128+
this.portalList={};
129+
130+
this.hasRoomWarp=false;
125131
this.roomWarp=[];
126132
this.warpPortalTexture=null;
127133
this.warpZoneRenderTarget=null;
@@ -255,6 +261,10 @@ class RoomEnvironment{
255261
}*/
256262
}
257263

264+
getName(){
265+
return this.roomName;
266+
}
267+
258268
getArtistInfo(){
259269
return null;
260270
}
@@ -339,6 +349,119 @@ class RoomEnvironment{
339349

340350
this.mouseRayHits=rayHits;
341351
}
352+
353+
// -- -- --
354+
355+
hasColliders(){
356+
return this.collidersExist
357+
}
358+
359+
hasColliderType( colliderType=COLLIDER_TYPE.FLOOR ){
360+
let hasCollidersOfType = false;
361+
if( !this.hasColliders() ){
362+
return hasCollidersOfType;
363+
}
364+
365+
switch( colliderType ){
366+
case COLLIDER_TYPE.FLOOR:
367+
hasCollidersOfType = this.colliderActive;
368+
break;
369+
case COLLIDER_TYPE.WALL:
370+
hasCollidersOfType = this.colliderActive;
371+
break;
372+
case COLLIDER_TYPE.TOP:
373+
hasCollidersOfType = this.antiColliderTopActive;
374+
break;
375+
case COLLIDER_TYPE.CEILING:
376+
// Not implemented yet
377+
break;
378+
case COLLIDER_TYPE.PORTAL_WARP:
379+
hasCollidersOfType = this.hasPortalExit;
380+
break;
381+
case COLLIDER_TYPE.ROOM_WARP:
382+
hasCollidersOfType = this.hasRoomWarp;
383+
break;
384+
case COLLIDER_TYPE.ITEM:
385+
// Not implemented yet
386+
break;
387+
case COLLIDER_TYPE.SCRIPTED:
388+
// Not implemented yet
389+
break;
390+
}
391+
392+
return hasCollidersOfType;
393+
}
394+
395+
// -- -- --
396+
397+
getColliders( colliderType=COLLIDER_TYPE.FLOOR ){
398+
let forHashing = [];
399+
if( !this.hasColliders() ){
400+
return forHashing;
401+
}
402+
403+
// Kick out if the collider type is not active
404+
// ( No colliders of the given type exist )
405+
if( colliderType == COLLIDER_TYPE.WALL && !this.antiColliderActive ){
406+
return forHashing;
407+
}else if( colliderType == COLLIDER_TYPE.TOP && !this.antiColliderTopActive ){
408+
return forHashing;
409+
}else if( colliderType == COLLIDER_TYPE.ROOM_WARP && !this.hasRoomWarp ){
410+
return forHashing;
411+
}else if( colliderType == COLLIDER_TYPE.PORTAL_WARP && !this.hasPortalExit ){
412+
return forHashing;
413+
}
414+
415+
switch( colliderType ){
416+
case COLLIDER_TYPE.FLOOR:
417+
forHashing = [
418+
...this.colliderList['noAxis'],
419+
...this.colliderList['11'],
420+
...this.colliderList['01'],
421+
...this.colliderList['10'],
422+
...this.colliderList['00']
423+
];
424+
break;
425+
case COLLIDER_TYPE.WALL:
426+
forHashing = [
427+
...this.colliderList['noAxis'],
428+
...this.colliderList['11'],
429+
...this.colliderList['01'],
430+
...this.colliderList['10'],
431+
...this.colliderList['00']
432+
];
433+
break;
434+
case COLLIDER_TYPE.TOP:
435+
forHashing = [
436+
...this.antiColliderTopList['noAxis'],
437+
...this.antiColliderTopList['11'],
438+
...this.antiColliderTopList['01'],
439+
...this.antiColliderTopList['10'],
440+
...this.antiColliderTopList['00']
441+
];
442+
break;
443+
case COLLIDER_TYPE.CEILING:
444+
// Not implemented yet
445+
break;
446+
case COLLIDER_TYPE.PORTAL_WARP:
447+
forHashing = this.portalList;
448+
break;
449+
case COLLIDER_TYPE.ROOM_WARP:
450+
forHashing = this.roomWarp;
451+
break;
452+
case COLLIDER_TYPE.ITEM:
453+
// Not implemented yet
454+
break;
455+
case COLLIDER_TYPE.SCRIPTED:
456+
// Not implemented yet
457+
break;
458+
default:
459+
break;
460+
}
461+
462+
//forHashing = this.colliderHashMap;
463+
return forHashing;
464+
}
342465

343466
toCameraPos( positionName ){
344467
if( this.cameraBooted && this.camLocation.hasOwnProperty( positionName ) ){

0 commit comments

Comments
 (0)