I want to create text in three.js. So I am trying to load the font and it is failing. Why?
const loader = new FontLoader();
loader.load(
'http://localhost:8080/src/store/fonts/noto_sans_kr_regular.json',
font => {
const color = 0x006699;
const matLite = new Three.MeshBasicMaterial({
color: color,
transparent: true,
opacity: 0.4,
side: Three.DoubleSide,
});
const message = ' Three.js\nSimple text.';
const shapes = font.generateShapes(message, 100);
const geometry = new Three.MeshBasicMaterial(shapes);
geometry.computeBoundingBox();
const xMid =
-0.5 *
(geometry.boundingBox.max.x - geometry.boundingBox.min.x);
geometry.translate(xMid, 0, 0);
// make shape ( N.B. edge view not visible )
const text = new Three.Mesh(geometry, matLite);
text.position.z = -150;
state.scene.add(text);
},
);
Above is my source code and below are the methods I have tried.
loader.load('http://localhost:8080/src/store/fonts/noto_sans_kr_regular.json'
loader.load('http://localhost:8080/@/store/fonts/noto_sans_kr_regular.json'
loader.load('/noto_sans_kr_regular.json'
loader.load('@/store/fonts/noto_sans_kr_regular.json'
loader.load('/src/store/fonts/noto_sans_kr_regular.json'
loader.load('./fonts/noto_sans_kr_regular.json'
This is the error code.
This is the path to the font file.
I don't know if other parts of the code are needed. sorry.



loader.load('@/store/fonts/noto_sans_kr_regular.json'seems okay in terms of path. Maybe also tryloader.load('@/src/store/fonts/noto_sans_kr_regular.json'. Otherwise, you're having a.jsonfile here, not really a font file (.otf,.ttf,.woffetc...) so this is probably one other issue to fix.store(used for Vuex in general).