File tree Expand file tree Collapse file tree 3 files changed +37
-32
lines changed Expand file tree Collapse file tree 3 files changed +37
-32
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " webgl-engine" ,
3
- "version" : " 1.0.2 " ,
3
+ "version" : " 1.0.3 " ,
4
4
"description" : " " ,
5
5
"main" : " src/index.ts" ,
6
6
"scripts" : {
Original file line number Diff line number Diff line change @@ -561,38 +561,43 @@ export class Engine<T> {
561
561
/// Apply the current texture if relevant
562
562
// Check if the current texture is loaded
563
563
if ( obj . texture && obj . texture . enabled !== false ) {
564
- if ( ! this . loader . isLoaded ( obj . texture . uri ) ) {
564
+ if (
565
+ ! this . loader . isLoaded ( obj . texture . uri ) ||
566
+ obj . texture . _computed === undefined
567
+ ) {
565
568
await this . _loadTextures ( ) ;
566
569
}
567
570
568
- const { webglTexture, square } = obj . texture . _computed ;
569
- gl . bindTexture ( gl . TEXTURE_2D , webglTexture ) ;
570
-
571
- if ( obj . texture . _computed ) {
572
- if ( square ) {
573
- gl . texParameteri (
574
- gl . TEXTURE_2D ,
575
- gl . TEXTURE_WRAP_S ,
576
- REPEAT_MAP [ obj . texture . repeat_horizontal ]
577
- ) ;
578
-
579
- gl . texParameteri (
580
- gl . TEXTURE_2D ,
581
- gl . TEXTURE_WRAP_T ,
582
- REPEAT_MAP [ obj . texture . repeat_vertical ]
583
- ) ;
584
- } else {
585
- gl . texParameteri (
586
- gl . TEXTURE_2D ,
587
- gl . TEXTURE_WRAP_S ,
588
- gl . CLAMP_TO_EDGE
589
- ) ;
590
-
591
- gl . texParameteri (
592
- gl . TEXTURE_2D ,
593
- gl . TEXTURE_WRAP_T ,
594
- gl . CLAMP_TO_EDGE
595
- ) ;
571
+ if ( obj && obj . texture ) {
572
+ const { webglTexture, square } = obj . texture . _computed ;
573
+ gl . bindTexture ( gl . TEXTURE_2D , webglTexture ) ;
574
+
575
+ if ( obj . texture . _computed ) {
576
+ if ( square ) {
577
+ gl . texParameteri (
578
+ gl . TEXTURE_2D ,
579
+ gl . TEXTURE_WRAP_S ,
580
+ REPEAT_MAP [ obj . texture . repeat_horizontal ]
581
+ ) ;
582
+
583
+ gl . texParameteri (
584
+ gl . TEXTURE_2D ,
585
+ gl . TEXTURE_WRAP_T ,
586
+ REPEAT_MAP [ obj . texture . repeat_vertical ]
587
+ ) ;
588
+ } else {
589
+ gl . texParameteri (
590
+ gl . TEXTURE_2D ,
591
+ gl . TEXTURE_WRAP_S ,
592
+ gl . CLAMP_TO_EDGE
593
+ ) ;
594
+
595
+ gl . texParameteri (
596
+ gl . TEXTURE_2D ,
597
+ gl . TEXTURE_WRAP_T ,
598
+ gl . CLAMP_TO_EDGE
599
+ ) ;
600
+ }
596
601
}
597
602
}
598
603
}
Original file line number Diff line number Diff line change @@ -131,8 +131,10 @@ export class Scene<T> {
131
131
this . objects . splice ( 0 , this . objects . length ) ;
132
132
this . vertexes = [ ] ;
133
133
this . texcoords = [ ] ;
134
+ this . colors = [ ] ;
134
135
this . vertexMetadata = { } ;
135
136
this . texcoordMetadata = { } ;
137
+ this . colorMetadata = { } ;
136
138
}
137
139
138
140
addObject ( obj : Obj3d ) {
@@ -142,8 +144,6 @@ export class Scene<T> {
142
144
const obj = queue . pop ( ) ;
143
145
if ( obj ) {
144
146
this . registerObject ( obj ) ;
145
- delete obj . vertexes ;
146
- delete obj . texcoords ;
147
147
this . objects . push ( obj ) ;
148
148
149
149
if ( obj . children ) {
You can’t perform that action at this time.
0 commit comments