HTML
CSS
JS
Result
Skip Results Iframe
EDIT ON
Live
Live
Live
This Pen is owned by
Klaas Nienhuis
on
CodePen
.
See more by @klaasnienhuis on CodePen
External CSS
https://codepen.io/klaasnienhuis/pen/eYXKXJr/b1f68cd57aafb94914a3dcf38c1403f9.css
External JavaScript
https://static.sketchfab.com/api/sketchfab-viewer-1.11.0.js
{"__browser":{"country":"US","device":"unknown_device","mobile":false,"name":"unknown browser","platform":"unknown_platform","version":"0"},"__constants":{},"__CPDATA":{"domain_iframe":"https://cdpn.io","environment":"production","host":"codepen.io","iframe_allow":"accelerometer *; ambient-light-sensor *; camera *; display-capture *; encrypted-media *; geolocation *; gyroscope *; microphone *; midi *; payment *; vr *; web-share *; serial *; xr-spatial-tracking *","iframe_sandbox":"allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups-to-escape-sandbox allow-popups allow-presentation allow-same-origin allow-scripts allow-top-navigation-by-user-activation"},"__graphql":{"data":{"errors":[{"message":"Cannot return null for non-nullable field Query.sessionUser"}],"data":null},"url":"https://codepen.io/graphql","api":"cprails"},"__pay_stripe_public_key":"pk_live_2GndomDfiklqpSNQn8FrGuwZSMIMzha7DkLJqlYe7IR0ihKAlKdiHg68JJc5eVPt68rzAjzAAVXcUwjySHRCsgjQQ00gtRBUFNH","__pay_braintree_env":"production","__boomboom":{"serve_url":"https://cdpn.io/cpe/boomboom","store_url":"https://codepen.io/cpe/boomboom/store"},"__pageType":"embed","__item":"{\"editor_settings\":{\"auto_run\":false,\"autocomplete\":false,\"code_folding\":true,\"css_pre_processor\":\"none\",\"css_prefix\":\"neither\",\"css_starter\":\"neither\",\"emmet_active\":true,\"font_size\":14,\"font_type\":\"system\",\"format_on_save\":true,\"html_pre_processor\":\"none\",\"indent_with\":\"spaces\",\"js_pre_processor\":\"none\",\"key_bindings\":\"normal\",\"line_numbers\":true,\"line_wrapping\":true,\"match_brackets\":true,\"snippets\":{\"markupSnippets\":{},\"stylesheetSnippets\":{}},\"tab_size\":2,\"theme\":\"twilight\",\"id\":\"Rwvbxxj\",\"auto_save\":false},\"hashid\":\"Rwvbxxj\",\"itemType\":\"pen\",\"resources\":[{\"url\":\"https://static.sketchfab.com/api/sketchfab-viewer-1.11.0.js\",\"order\":0,\"resource_type\":\"js\",\"par_content\":\"\"},{\"url\":\"https://codepen.io/klaasnienhuis/pen/eYXKXJr/b1f68cd57aafb94914a3dcf38c1403f9.css\",\"order\":0,\"resource_type\":\"css\",\"par_content\":\"\"}],\"tags\":[\"sketchfab\",\"api\",\"viewerapi\",\"3d\"],\"id\":71174350,\"user_id\":2407400,\"html\":\"<div class=\\\"sidebar\\\">\\n <h2>Linear interpolation</h2>\\n <input class=\\\"slider\\\" type=\\\"range\\\" min=\\\"0\\\" max=\\\"1\\\" step=\\\"0.01\\\" value=\\\"0\\\" id=\\\"linear\\\">\\n <h2>Ease in-out</h2>\\n <input class=\\\"slider\\\" type=\\\"range\\\" min=\\\"0\\\" max=\\\"1\\\" step=\\\"0.01\\\" value=\\\"0\\\" id=\\\"ease\\\">\\n <h2>Both at the same time</h2>\\n <input class=\\\"slider\\\" type=\\\"range\\\" min=\\\"0\\\" max=\\\"1\\\" step=\\\"0.01\\\" value=\\\"0\\\" id=\\\"both\\\">\\n</div>\\n<div class=\\\"devfab-label\\\">Find the tutorial on <a href=\\\"https://www.devfab.io/guide/annotations/create.html\\\">devfab.io</a></div>\\n<iframe id=\\\"api-frame\\\"></iframe>\",\"css\":\"html,\\nbody {\\n font-family: Avenir, Helvetica, Arial, sans-serif;\\n text-align: center;\\n color: #2c2c2c;\\n padding: 0;\\n margin: 0;\\n width: 100vw;\\n height: 100vh;\\n overflow: hidden;\\n}\\n\\niframe {\\n width: 100%;\\n height: 100%;\\n border: 0;\\n}\\n\\n.slider {\\n width: 200px;\\n}\\n\\n.sidebar {\\n position: absolute;\\n width: 250px;\\n left: 0px;\\n top: 0px;\\n padding: 20px;\\n text-align: left;\\n display: flex;\\n flex-direction: column;\\n pointer-events: all;\\n overflow-y: auto;\\n background-color: #c3c3c300;\\n}\\n\",\"js\":\"const scenematerials = {\\n slide: null,\\n plane: null\\n};\\n\\nconst setColor = (api, materialName, newColor) => {\\n const material = scenematerials[materialName];\\n material.channels.AlbedoPBR.color = newColor;\\n api.setMaterial(material);\\n};\\n\\nconst easeLinear = (x) => {\\n return [1 - x, x, 0];\\n};\\n\\nconst easeInOut = (x) => {\\n const value =\\n x < 0.5 ? 16 * x * x * x * x * x : 1 - Math.pow(-2 * x + 2, 5) / 2;\\n return [1 - value, value, 0];\\n};\\n\\nconst success = (api) => {\\n api.addEventListener(\\\"viewerready\\\", function () {\\n api.getMaterialList((err, materials) => {\\n materials.forEach((item) => {\\n if (scenematerials[item.name] === null)\\n scenematerials[item.name] = item;\\n });\\n // start two materials with a red color\\n setColor(api, \\\"slide\\\", [1, 0, 0]);\\n setColor(api, \\\"plane\\\", [1, 0, 0]);\\n });\\n document.getElementById(\\\"linear\\\").addEventListener(\\\"input\\\", (event) => {\\n const sliderValue = parseFloat(event.target.value);\\n const newColorLinear = easeLinear(sliderValue);\\n setColor(api, \\\"slide\\\", newColorLinear);\\n });\\n document.getElementById(\\\"ease\\\").addEventListener(\\\"input\\\", (event) => {\\n const sliderValue = parseFloat(event.target.value);\\n const newColorEase = easeInOut(sliderValue);\\n setColor(api, \\\"plane\\\", newColorEase);\\n });\\n document.getElementById(\\\"both\\\").addEventListener(\\\"input\\\", (event) => {\\n const sliderValue = parseFloat(event.target.value);\\n const newColorLinear = easeLinear(sliderValue);\\n setColor(api, \\\"slide\\\", newColorLinear);\\n const newColorEase = easeInOut(sliderValue);\\n setColor(api, \\\"plane\\\", newColorEase);\\n });\\n });\\n};\\n\\nconst loadSketchfab = (sceneuid, elementId) => {\\n const iframe = document.getElementById(elementId);\\n const client = new Sketchfab(\\\"1.12.1\\\", iframe);\\n\\n client.init(sceneuid, {\\n success: success,\\n error: () => console.error(\\\"Sketchfab API error\\\"),\\n autostart: 0,\\n ui_controls: 0,\\n ui_infos: 0,\\n ui_watermark: 0,\\n ui_stop: 0\\n });\\n};\\n\\nloadSketchfab(\\\"b335a0ddc78d490e9f99d0171eb5bfe4\\\", \\\"api-frame\\\");\\n\",\"html_pre_processor\":\"none\",\"css_pre_processor\":\"none\",\"js_pre_processor\":\"none\",\"html_classes\":\"\",\"css_starter\":\"neither\",\"js_library\":null,\"created_at\":\"2023-10-20T09:08:16.713Z\",\"updated_at\":\"2024-02-07T10:43:44.344Z\",\"title\":\"Sketchfab Materials - interpolation with slider\",\"description\":\"Load a 3D Sketchfab model of a skull. Open and close the jaw when you drag a slider. And change the post processing at the same time.\",\"slug_hash\":\"Rwvbxxj\",\"head\":\"\",\"private\":false,\"has_animation\":false,\"team_id\":0,\"css_prefix\":\"neither\",\"template\":false,\"parent_id\":28789574,\"comments_count\":0,\"custom_screenshot_filename\":null,\"loves_count\":0,\"pick\":false,\"popularity_score\":0,\"views_count\":0,\"pick_visible_at\":null,\"cpid\":\"018b4c57-aec9-78b4-b1f9-becccdcc1930\",\"is_new_editor_pen\":false,\"protected\":false,\"access\":\"Public\",\"pen_hash\":null}","__processorsMap":{"autoprefixer":"autoprefixer-10","babel":"babel-7","coffeescript":"coffeescript-2","format-1":"format-1","flutter":"flutter-1","haml":"haml-4","less":"less-3","lint-1":"lint-1","livescript":"livescript-1","markdown":"markdown-11","postcss":"postcss-7","pug":"pug-2","sass":"sass-1","scss":"sass-1","sass-ruby-3":"sass-ruby-3","sass-ruby-compass-3":"sass-ruby-compass-3","slim":"slim-3","stylus":"stylus-0","typescript":"typescript-4","vue":"vue-2","vue3":"vue-3"},"__favicon_mask_icon":"https://cpwebassets.codepen.io/assets/favicon/logo-pin-b4b4269c16397ad2f0f7a01bcdf513a1994f4c94b8af2f191c09eb0d601762b1.svg","__favicon_shortcut_icon":"https://cpwebassets.codepen.io/assets/favicon/favicon-aec34940fbc1a6e787974dcd360f2c6b63348d4b1f4e06c77743096d55480f33.ico","__path_to_iframe_console_runner":"https://cpwebassets.codepen.io/assets/editor/iframe/iframeConsoleRunner-6d8bf8b4b479137260842506acbb12717dace0823c023e08b96360e60b0840d9.js","__path_to_iframe_refresh_css":"https://cpwebassets.codepen.io/assets/editor/iframe/iframeRefreshCSS-44fe83e49b63affec96918c9af88c0d80b209a862cf87ac46bc933074b8c557d.js","__path_to_iframe_runtime_errors":"https://cpwebassets.codepen.io/assets/editor/iframe/iframeRuntimeErrors-4f205f2c14e769b448bcf477de2938c681660d5038bc464e3700256713ebe261.js","__path_to_processor_worker":"https://cpwebassets.codepen.io/assets/packs/router.js","__path_to_stop_execution_on_timeout":"https://cpwebassets.codepen.io/assets/common/stopExecutionOnTimeout-2c7831bb44f98c1391d6a4ffda0e1fd302503391ca806e7fcc7b9b87197aec26.js","__pen_normalize_css_url":"https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css","__pen_prefix_free_url":"https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js","__pen_reset_css_url":"https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css","__path_to_infinite_loop_detection":"https://cpwebassets.codepen.io/assets/packs/js/infiniteLoopDetection-22d4d33aab19e5279e72.js"}