File tree 3 files changed +11
-1
lines changed 3 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,9 @@ Demo at [jons.website/projects/reaction-diffusion](https://jons.website/projects
32
32
- This is a float value greater than 0. Higher numbers mean the peaks are closer together.
33
33
- If you don't set this value, a circular non-random seed is used instead.
34
34
- A good way to debug this is to set the time scale to 0. That way, the simulation will stay with whatever the initial seed is.
35
+ * For speed, you can force half-precision float precision by setting `force-half-precision="true"`.
36
+ - `<div class="reaction-diffusion-container" force-half-precision="true"></div>`
37
+ - Valid values are "true" or "false". If you don't specify, it'll default to "false".
35
38
36
39
## Building
37
40
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ export class ReactionDiffusionRenderer {
43
43
this . CheckWebGLSupport ( ) ;
44
44
45
45
// Configure renderer based on available texture float precision
46
- if ( this . DetectTextureFloat ( ) ) {
46
+ if ( this . DetectTextureFloat ( ) && ! this . forceHalfPrecision ) {
47
47
console . log ( "Using full-precision float textures" ) ;
48
48
this . imageType = THREE . FloatType ;
49
49
@@ -110,6 +110,10 @@ export class ReactionDiffusionRenderer {
110
110
this . allowInteraction = optionalParams . allowInteraction ;
111
111
console . log ( `Using allow-interaction value from HTML attributes = ${ optionalParams . allowInteraction } ` ) ;
112
112
}
113
+ if ( optionalParams . forceHalfPrecision != null ) {
114
+ this . forceHalfPrecision = optionalParams . forceHalfPrecision
115
+ console . log ( `Using force-half-precision value from HTML attributes = ${ optionalParams . forceHalfPrecision } ` ) ;
116
+ }
113
117
114
118
this . ReformRenderTargets ( width , height ) ;
115
119
this . Reset ( ) ;
Original file line number Diff line number Diff line change @@ -86,6 +86,9 @@ export class ReactionDiffusion {
86
86
let allowInteraction = container . getAttribute ( "allow-interaction" ) ;
87
87
if ( allowInteraction ) params [ "allowInteraction" ] = allowInteraction == "true" ;
88
88
89
+ let forceHalfPrecision = container . getAttribute ( "force-half-precision" ) ;
90
+ if ( forceHalfPrecision ) params [ "forceHalfPrecision" ] = forceHalfPrecision == "true" ;
91
+
89
92
return params ;
90
93
}
91
94
You can’t perform that action at this time.
0 commit comments