3d-force-graph icon indicating copy to clipboard operation
3d-force-graph copied to clipboard

Uncaught TypeError: material.onBeforeRender is not a function

Open piaoxiaobo opened this issue 3 years ago • 1 comments

image

this.Graph = this.$Graph3D({ extraRenderers: [new CSS2DRenderer()], rendererConfig: {}, })

		// instantiate a loader
		const loader = new OBJLoader()
		const _this = this
		// load a resource
		loader.load(
			// resource URL
			"model/board.obj",
			// called when resource is loaded
			function (object) {
				console.log(object)
				_this.Graph.scene().add(object)
			},
			// called when loading is in progresses
			function (xhr) {
				console.log((xhr.loaded / xhr.total) * 100 + "% loaded")
			}
			// called when loading has errors
			// function (error) {
			// 	console.log("An error happened")
			// }
		)

piaoxiaobo avatar Dec 14 '21 15:12 piaoxiaobo

问题已经解决了,是因为three js版本不同导致,修改项目package.json文件里的three版本与3d-force-graph引用的threejs版本一致即可。之前加载模型等有问题的朋友可以尝试一下,祝各位好运~ The problem has been solved, because the three js version is different, just modify the three version in the project package.json file to be consistent with the threejs version referenced by 3d-force-graph. Friends who have problems with loading models before can try it out, good luck to everyone. image

image image

piaoxiaobo avatar Dec 14 '21 17:12 piaoxiaobo