Comments (6)
increase the budget in asconfig.json:options.memoryBase ( say, 655360 = 640kB )
Line 18 in 0d0c942
then rebuild (npm run asbuild)
🥂
from babylon.font.
Okay, that makes sense. Thanks for the quick reply!
Is there a way to calculate what values will be a problem for a given font, or is the only way to wrap every call to builder.create
with error handling to catch this error?
from babylon.font.
Hmm. I can't seem to recover from this error at all. I've even tried reloading the entire complier mechanism (which would be pretty heavy to do every time this error occurs) to no avail.
All subsequent calls to builder.create
fail with the same error.
Here is (roughly) the reloading code I attempted:
let compiler = await Compiler.Build(`${constants.BABYLON_FONT_WASM}`)
let fonts: { [key in FontName]: Font } = {
calibri: await Font.Install(fontPaths.calibri, compiler, opentype),
consola: await Font.Install(fontPaths.consola, compiler, opentype),
'consola-bold': await Font.Install(
fontPaths['consola-bold'],
compiler,
opentype,
),
}
let builder = new TextMeshBuilder(BABYLON, earcut)
try {
mesh = builder.create(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
{
font: fonts.calibri,
text: failingText,
size: 12,
},
scene,
)
} catch (error) {
Compiler.Build(`${constants.BABYLON_FONT_WASM}`).then(
async (newCompiler) => {
compiler = newCompiler
fonts = {
calibri: await Font.Install(
fontPaths.calibri,
compiler,
opentype,
),
consola: await Font.Install(
fontPaths.consola,
compiler,
opentype,
),
'consola-bold': await Font.Install(
fontPaths['consola-bold'],
compiler,
opentype,
),
}
builder = new TextMeshBuilder(BABYLON, earcut)
builder.create(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
{
font: fonts.calibri,
text: 'small',
size: 12,
},
makeOpts.scene,
)
},
)
}
from babylon.font.
a workaround off the top of my head
bytes required for (font, text)
can be computed by:
function bytes_required(font, text) {
let b = 0
const cmds = font.raw.getPath(text, 0, 0, 100).commands
for (const cmd of cmds) {
b += 1
switch (cmd.type) {
case 'M':
case 'L': b += 16; break
case 'Q': b += 48; break
case 'C': b += 64; break
}
}
return b
}
then, validate before each builder.create
:
if ( bytes_required(font, 'hello') <= 65536 ) {
// builder.create( .. )
}
where 65536 := asconfig.json:options.memoryBase
🥂
from babylon.font.
Awesome. Thanks again! I'll give this a shot.
from babylon.font.
solved in v4.
from babylon.font.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from babylon.font.