{"id":309876,"date":"2020-09-14T09:00:09","date_gmt":"2020-09-14T09:00:09","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=309876"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=309876","title":{"rendered":"\u041e\u043f\u044b\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 3\u0434 \u0441\u0446\u0435\u043d \u0431\u0435\u0437 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b (three.js)"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/519008\/\">\n<h2>\u0427\u0442\u043e \u0434\u0435\u043b\u0430\u044e<\/h2>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043b\u0438\u0447\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0440\u0430\u0437\u043d\u044b\u0445 gltf \u043c\u043e\u0434\u0435\u043b\u0435\u0439.<\/p>\n<p>  <\/p>\n<p>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043e\u043f\u044b\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 three.js \u0443 \u043c\u0435\u043d\u044f \u0431\u044b\u043b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u043f\u043e\u0441\u043b\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 GLTFLoader, \u0431\u044b\u043b\u0430 \u0432\u044b\u0431\u0440\u0430\u043d\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0435 \u043e \u0441\u0446\u0435\u043d\u0430\u0445 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c json \u0444\u0430\u0439\u043b\u0435 \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u0443\u0442\u0438 \u043a \u0441\u0446\u0435\u043d\u0435, \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u0438, \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0435 \u043a\u0430\u043c\u0435\u0440\u044b \u0438 \u0442.\u0434. \u043d\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0435 \u043e\u043d\u0438 \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442 \u0432 \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u043c\u0435\u0440\u0435.  <\/p>\n<p>  <\/p>\n<p>\u0412 \u0442\u0435\u043e\u0440\u0438\u0438 \u0431\u044b\u043b\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u0440\u044f\u0434 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0446\u0435\u043d. \u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0432\u0441\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0439.<\/p>\n<p> <a name=\"habracut\"><\/a>  <\/p>\n<h2>\u041a\u0430\u043a \u0434\u0435\u043b\u0430\u044e<\/h2>\n<p>  <\/p>\n<h3>\u041a\u0430\u043c\u0435\u0440\u0430<\/h3>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u043b\u0430\u0441\u044c \u0432 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0438 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u0434\u043b\u044f \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u043a\u0430\u043c\u0435\u0440\u044b. \u0418\u0437 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439 \u043a <br \/>   \u043a\u0430\u043c\u0435\u0440\u0435 \u0438 \u043f\u0435\u0440\u0435\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044e:  <\/p>\n<p>  <\/p>\n<ul>\n<li>\u041a\u0430\u043c\u0435\u0440\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u0442\u043e\u0447\u043a\u0430\u043c, \u0434\u043e\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u044f \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435;<\/li>\n<li>\u043a\u0430\u043c\u0435\u0440\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u0441\u043a\u0440\u043e\u043b\u043b\u0430 \u043a\u043e\u043b\u0435\u0441\u0430 \u043c\u044b\u0448\u043a\u0438 (\u043f\u0435\u0440\u0435\u0434\u0432\u0438\u0433\u0430\u044f\u0441\u044c \u0432\u043f\u0435\u0440\u0435\u0434 \u0438 \u043d\u0430\u0437\u0430\u0434, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e);<\/li>\n<li>\u043a\u0430\u043c\u0435\u0440\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u043b\u0430\u0432\u043d\u043e \u00ab\u0442\u043e\u0440\u043c\u043e\u0437\u0438\u0442\u044c\u00bb \u0438 \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0435 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u0438 \u043f\u0443\u0442\u0438 \u043f\u043e\u0434\u043e\u0448\u0435\u043b CatmullRomCurve3 \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c getPoint(), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0442\u0440\u043e\u0438\u043b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043b\u0430\u0432\u043d\u0443\u044e \u043a\u0440\u0438\u0432\u0443\u044e. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u043a\u0440\u0438\u0432\u044b\u0445, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a Curve \u0438\u043b\u0438 CubicBezierCurve3 \u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 \u043d\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043b\u0430\u0432\u043d\u043e. \u042d\u0442\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u0432\u044f\u0437\u043a\u0430 \u0441\u043a\u0440\u043e\u043b\u043b\u0430 \u043c\u044b\u0448\u0438 \u043a \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044e \u043a\u0430\u043c\u0435\u0440\u044b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0432 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043a\u0440\u043e\u043b\u043b\u0430, \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 (\u043f\u0440\u0438\u0431\u0430\u0432\u043a\u043e\u0439 \u0438\u043b\u0438 \u0432\u044b\u0447\u0435\u0442\u043e\u043c \u0434\u0435\u043b\u044c\u0442\u044b). \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u0435\u043b\u0438\u043c \u043d\u0430 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043a\u0430\u043c\u0435\u0440\u044b \u0434\u043e \u0435\u0435 \u0446\u0435\u043d\u0442\u0440\u0430 (\u043f\u043e \u0438\u043a\u0441\u0443). \u042d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0432 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0446\u0435\u043d\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u043e\u0442 \u0446\u0435\u043d\u0442\u0440\u0430, \u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u043a\u0430\u043c\u0435\u0440\u044b (\u043f\u043e \u0438\u043a\u0441\u0443) \u0440\u043e\u0432\u043d\u0430 \u043d\u0443\u043b\u044e. \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0435 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0435, \u043d\u043e \u044f \u043f\u0440\u0438\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u043b\u0441\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u043b \u043f\u0440\u043e\u0435\u043a\u0442.  <\/p>\n<p>  <\/p>\n<p>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u0431\u044b\u043b\u0430 \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0438 \u0441 \u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435\u043c \u043a\u0430\u043c\u0435\u0440\u044b. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f TrackballControls \u0441 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u043c \u0444\u043e\u043a\u0443\u0441\u043e\u043c \u0432 \u0442\u043e\u0447\u043a\u0435 (0, 0, 0). \u041f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f (W, S, D, A \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435), \u0444\u043e\u043a\u0443\u0441 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044e \u043f\u043e \u043a\u0440\u0438\u0432\u043e\u0439, \u0441\u043c\u044f\u0433\u0447\u0438\u0442\u044c (\u0432 \u043e\u0431\u043e\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0442\u0430\u0439\u043c\u0435\u0440\u044b).   <\/p>\n<p>  <\/p>\n<h3>\u041f\u0430\u043c\u044f\u0442\u044c<\/h3>\n<p>  <\/p>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434\u0440\u044f\u0434 \u0438\u0434\u0443\u0449\u0438\u0445 \u0441\u0446\u0435\u043d \u043e\u0431\u0440\u0430\u0442\u0438\u043b \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e fps \u0441 \u043a\u0430\u0436\u0434\u043e\u0439 \u043d\u043e\u0432\u043e\u0439 \u043f\u043e\u0434\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u043f\u0430\u0434\u0430\u0435\u0442. \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0433\u0434\u0435-\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0443\u0442\u0435\u0447\u043a\u0430 \u043f\u0430\u043c\u044f\u0442\u0438. \u0414\u0435\u043b\u0430\u044e \u0441\u043d\u0430\u043f\u0448\u043e\u0442\u044b \u0434\u043b\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u0446\u0435\u043d. \u041f\u043e\u0434\u0447\u0438\u0449\u0430\u044e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0435\u043b\u043e\u0447\u0438. \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u044e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.  <\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/1s\/j4\/lt\/1sj4ltmci33vns-wqdfc6odlw5i.png\">  <\/p>\n<p>  <\/p>\n<p>\u041d\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442, \u043a\u0430\u043a \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430. \u041e\u0434\u043d\u0430\u043a\u043e, \u0444\u043f\u0441 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u043f\u0430\u0434\u0430\u0442\u044c. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440 \u0437\u0430\u0434\u0430\u0447 \u0445\u0440\u043e\u043c\u0430, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0432 \u0447\u0435\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430. \u0412\u044b\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043f\u0430\u043c\u044f\u0442\u044c GPU \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0441\u0446\u0435\u043d \u043d\u0435 \u043e\u0447\u0438\u0449\u0430\u0435\u0442\u0441\u044f, \u0430 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u0437\u0430\u0431\u0438\u0432\u0430\u0442\u044c\u0441\u044f.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0432 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b \u043d\u0430 \u0442\u0435\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f three.js \u0432 SPA (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0442 <a href=\"https:\/\/medium.com\/@driesdesmet_69747\/a-tale-of-three-js-snapshots-and-angular-2-or-how-memory-leaks-bad4e9882669\" rel=\"nofollow\">\u0414\u0440\u0438\u0435\u0441\u0430 \u0414\u0435 \u0421\u043c\u0435\u0442\u0430<\/a>) \u0432\u044b\u044f\u0441\u043d\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u0446\u0435\u043d\u044b \u043d\u0435 \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">for (let i = mScene.scene.children.length - 1; i &gt;= 0; i--) {     mScene.scene.remove(mScene.scene.children[i]); \/\/ \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043f\u0440\u043e\u043f\u0430\u0434\u0430\u044e\u0442, \u043d\u043e \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 } <\/code><\/pre>\n<p>  <\/p>\n<p>\u0411\u043e\u043b\u0435\u0435. \u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438 \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u043c\u0435\u0442\u043e\u0434\u0430 \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0438 \u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432\u0435\u0441\u044c\u043c\u0430 \u0440\u0430\u0441\u043f\u043b\u044b\u0432\u0447\u0430\u0442\u044b. \u0412\u043e\u0442 \u0447\u0442\u043e \u043f\u0438\u0448\u0443\u0442 \u043e \u043c\u0435\u0442\u043e\u0434\u0435 dispose() \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438:<\/p>\n<p>  <\/p>\n<blockquote><p>In general, there is no definite recommendation for this. It highly depends on the specific use case when calling dispose() is appropriate. It&#8217;s important to highlight that it&#8217;s not always necessary to dispose objects all the time. A good example for this is a game which consists of multiple levels. <\/p><\/blockquote>\n<p>  <\/p>\n<p>\u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c dispose. \u041d\u043e \u043a\u0430\u043a? \u042d\u043c\u043f\u0438\u0440\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u0438\u0448\u0435\u043b \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0443 (\u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0432 \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435):<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">dispose_scene() {     let self = this;     self.scroll_timer_stop();     this.scene.traverse(function (object) {     self.scroll_timer_stop();         if (object.type === &quot;Mesh&quot; || object.type === &quot;Group&quot;) {             self.dispose_hierarchy(object, self.dispose_node);             self.scene.remove(object);             object = null;        }     }); }  dispose_hierarchy(node, callback) {     for (var i = node.children.length - 1; i &gt;= 0; i--) {         var child = node.children[i];         this.dispose_hierarchy(child, callback);         callback(child);     } }  dispose_node(node) {         if (node.constructor.name === &quot;Mesh&quot;) {             node.parent = undefined;             if (node.geometry) {                 node.geometry.dispose();             }             if (node.geometry) {                 node.geometry.dispose();             }             let material = node.material;             if (material) {                 if (material.map) {                     material.map.dispose();                 }                 if (material.lightMap) {                     material.lightMap.dispose();                 }                 ...                 material.dispose();                 material = undefined;             }         } else if (node.constructor.name === &quot;Object3D&quot;) {             node.parent.remove(node);             node.parent = null;         } }  dispose_postprocessing() {          this.postprocessing.rtTextureColors.dispose();         this.postprocessing.rtTextureDepth.dispose();         ...         this.postprocessing.materialGodraysDepthMask.dispose();         this.postprocessing.materialGodraysGenerate.dispose();         ... } <\/code><\/pre>\n<p>  <\/p>\n<h2>\u0418\u0442\u043e\u0433<\/h2>\n<p>  <\/p>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u0430\u043c\u044f\u0442\u044c\u044e \u0432 three.js \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u0435 \u0438 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0435. this.postprocessing.dispose() \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0435 \u0442\u0430\u043a \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u043e\u0431\u0449\u0438\u0439 \u0440\u0430\u0441\u0445\u043e\u0434 \u043f\u0430\u043c\u044f\u0442\u0438, \u0430 \u0432\u043e\u0442 \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e\u0435 \u0438 \u043c\u0435\u0442\u043e\u0434\u0438\u0447\u043d\u043e\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0445, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c dispose() \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0442\u044b \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0435\u0448\u044c \u043f\u043b\u0430\u0442\u0438\u0442\u044c \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438 \u0437\u0430 \u0442\u043e, \u0447\u0435\u0433\u043e \u043d\u0435 \u0432\u0438\u0434\u0438\u0448\u044c. \u0425\u043e\u0442\u044f, \u0431\u0435\u0437\u0443\u0441\u043b\u043e\u0432\u043d\u043e, \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u044f \u043d\u0435 \u043d\u0430\u0448\u0435\u043b. \u0411\u043e\u043b\u0435\u0435. \u041d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043d\u0430 \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u0440\u0442\u0443 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043e\u0433\u0440\u043e\u043c\u043d\u0430\u044f. Geforce 2070 super \u0432\u044b\u0434\u0430\u0435\u0442 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0439 \u0444\u043f\u0441 \u0438 \u043f\u043b\u0430\u0432\u043d\u043e\u0441\u0442\u044c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0439, \u043d\u043e \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/pn\/yp\/1b\/pnyp1b0qad-54pobrme3sg47aym.png\">  <\/p>\n<p>  <\/p>\n<p>\u0411\u044b\u043b \u0431\u044b \u0440\u0430\u0434 \u0443\u0441\u043b\u044b\u0448\u0430\u0442\u044c \u0432\u0430\u0448\u0438 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u0438 \u043e\u043f\u044b\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u043c\u0438. \u0421 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c \u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0432 <a href=\"https:\/\/github.com\/trtr7dr\/multiscene\" rel=\"nofollow\">\u043c\u043e\u0435\u043c \u0433\u0438\u0442\u0445\u0430\u0431\u0435<\/a>. \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/519008\/\"> https:\/\/habr.com\/ru\/post\/519008\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/519008\/\">\n<h2>\u0427\u0442\u043e \u0434\u0435\u043b\u0430\u044e<\/h2>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043b\u0438\u0447\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0440\u0430\u0437\u043d\u044b\u0445 gltf \u043c\u043e\u0434\u0435\u043b\u0435\u0439.<\/p>\n<p>  <\/p>\n<p>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043e\u043f\u044b\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 three.js \u0443 \u043c\u0435\u043d\u044f \u0431\u044b\u043b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u043f\u043e\u0441\u043b\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 GLTFLoader, \u0431\u044b\u043b\u0430 \u0432\u044b\u0431\u0440\u0430\u043d\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0435 \u043e \u0441\u0446\u0435\u043d\u0430\u0445 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c json \u0444\u0430\u0439\u043b\u0435 \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u0443\u0442\u0438 \u043a \u0441\u0446\u0435\u043d\u0435, \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u0438, \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0435 \u043a\u0430\u043c\u0435\u0440\u044b \u0438 \u0442.\u0434. \u043d\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0435 \u043e\u043d\u0438 \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442 \u0432 \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u043c\u0435\u0440\u0435.  <\/p>\n<p>  <\/p>\n<p>\u0412 \u0442\u0435\u043e\u0440\u0438\u0438 \u0431\u044b\u043b\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u0440\u044f\u0434 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0446\u0435\u043d. \u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0432\u0441\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0439.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-309876","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/309876","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=309876"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/309876\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=309876"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=309876"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=309876"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}